Displaying lists of data
If your application needs to generally display small amount of tabular data, the standard ListCtrl
component can be a quick and easy way to present this data to users. ListCtrl
can operate in a number of visual modes that present data in a different way to the user. The report mode is the mode that we are going to take a look at in this recipe as it allows us to build a multicolumn table to display the data in.
How to do it…
Here are the steps that you need to perform:
First, let's make a custom
ListCtrl
base class to add some useful helper functions to, as follows:class BaseList(wx.ListCtrl): def __init__(self, parent): super(BaseList, self).__init__(parent, style=wx.LC_REPORT) self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRClick) self.Bind(wx.EVT_MENU, self.OnMenu, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.OnMenu, id=wx.ID_SELECTALL)
Next, let's define the event handlers that were specified...