The VListBox
control is much like a ListBox
control, but it is virtual (it doesn't store the data internally) and allows for items to have variable row heights. It works by providing a number of virtual callback methods that you must override in a subclass in order to draw the items on demand. Because of this requirement to override pure virtual methods, the VListBox
will always be subclassed. This recipe shows how to create a VListBox
derived control that supports an icon and text in each of its items.
To create our user list control, we just need to subclass a VListBox
and override some of its callback methods to perform the necessary actions:
class UserListBox(wx.VListBox): """Simple List Box control to show a list of users""" def __init__(self, parent, users): """@param users: list of user names""" super(UserListBox, self).__init__(parent) # Attributes # system-users.png is a sample image provided with ...