wxPython: combining wxListCtrl and wxCheckBox

Discussion in 'Python' started by Mark Carter, Dec 1, 2003.

  1. Mark Carter

    Mark Carter Guest

    I would like a wxListCtrl with 3 columns in it. The number of rows in
    it will vary during run-time. In the first column of each row should
    be a wxCheckBox, which the user can check or uncheck.

    Is such an arrangement possible?
    Any example source code?

    wxCheckListBox comes close - but not close enough. Unfortunately, it
    does not derive from wxListCtrl, which contains the function
    InsertColumn() needed for multiple columns
     
    Mark Carter, Dec 1, 2003
    #1
    1. Advertising

  2. Mark Carter

    Steve Zatz Guest

    One way to do this is to use the capability of the ListCtrl to display
    images in the first position in the row. You can create checked and
    unchecked images and then insert whichever image is appropriate for a
    given row in the List.

    When the row is created,
    LCtrl.InsertImageStringItem(...) can insert the appropriate image and
    you can then add as many additional columns as you need with
    LCtrl.SetStringItem(row, column, string)

    If some event changes the checkbox status of a row:

    LC_Item = LCtrl.GetItem(row)

    if __some condition__:
    LC_Item.SetImage(index_unchecked)
    else:
    LC_Item.SetImage(index_checked)

    LCtrl.SetItem(LC_Item)


    (Mark Carter) wrote in message news:<>...
    > I would like a wxListCtrl with 3 columns in it. The number of rows in
    > it will vary during run-time. In the first column of each row should
    > be a wxCheckBox, which the user can check or uncheck.
    >
    > Is such an arrangement possible?
    > Any example source code?
    >
    > wxCheckListBox comes close - but not close enough. Unfortunately, it
    > does not derive from wxListCtrl, which contains the function
    > InsertColumn() needed for multiple columns
     
    Steve Zatz, Dec 1, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piet
    Replies:
    3
    Views:
    522
  2. Piet
    Replies:
    4
    Views:
    1,488
    RichH
    Jul 5, 2004
  3. Piet
    Replies:
    0
    Views:
    588
  4. Fabio Pliger

    wxpython wxlistctrl with combo

    Fabio Pliger, Jun 13, 2005, in forum: Python
    Replies:
    1
    Views:
    402
    Franz Steinhaeusler
    Jun 14, 2005
  5. imperialguy
    Replies:
    0
    Views:
    194
    imperialguy
    Apr 13, 2011
Loading...

Share This Page