wxPython: combining wxListCtrl and wxCheckBox

M

Mark Carter

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
 
S

Steve Zatz

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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top