wxPython: combining wxListCtrl and wxCheckBox

Steve Zatz slzatz at hotmail.com
Mon Dec 1 11:21:14 EST 2003


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)


cartermark46 at ukmail.com (Mark Carter) wrote in message news:<d3c9c04.0312010235.7fbc53e0 at posting.google.com>...
> 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




More information about the Python-list mailing list