I am trying to use a ListCtrl widget in wxPython 2.4.2.1
which gets updated when the wx.EVT_IDLE event is processed.
The OnIdle event function I created is called, the new item
is added to the ListCtrl widget, and in code I can verify
the item is there....but no text is ever displayed in the
ListCtrl widget. The vertical scroll bar even becomes
visible when enough items have been added.
If I update the ListCtrl widget from a direct button click
instead of on idle events then text is displayed as
expected.
Anyone have a solution to this? Unfortunately upgrading to
a newer version of wxPython is not possible.
Below is the relevant bits of code.
--David
def OnInit(self):
...
self.listBox = wx.ListCtrl(self, -1,
style = wx.LC_REPORT
> wx.LC_SINGLE_SEL
> wx.LC_HRULES
> wx.LC_VRULES
> wx.SUNKEN_BORDER,
size = (485, 450))
wx.EVT_IDLE(self.listBox, self.OnIndexBoxIdle)
self.listBox.InsertColumn(0, "Type")
self.listBox.InsertColumn(1, "Log File Time")
self.listBox.InsertColumn(2, "Packet Time")
self.listBox.InsertColumn(3, "AppID")
self.listBox.SetColumnWidth(0, 100)
self.listBox.SetColumnWidth(1, 160)
self.listBox.SetColumnWidth(2, 160)
self.listBox.SetColumnWidth(3, 50)
#end def OnIndexBoxIdle
...
def OnIndexBoxIdle(self, evt):
if len(self.__newData) > 0:
# self.__newData gets populated with items to
# add to self.listBox
data = self.__newData.pop(0)
item = self.listBox.GetItemCount()
self.listBox.InsertStringItem(item, data['type'])
self.listBox.SetStringItem(item, 1, str(data['time']))
ptime = self.__reader.GetSendTime(data['offset'])
if ptime: self.listBox.SetStringItem(item, 2, str(ptime))
else : self.listBox.SetStringItem(item, 2, "")
self.listBox.SetStringItem(item, 3, str(data['appid']))
self.listBox.EnsureVisible(item)
#end if
#end def OnIndexBoxIdle