Hello,
I'm trying to add a custom listcontrol to an XRC dialog following the
TwoStageCreation description in the wiki.
As suggested in the example, I am adding columns to my control in the wx.EVT_WINDOW_CREATE handler.
However, I don't understand at which point I can safely use the created widget, i.e. add items to the columns.
In the following example application where a dialog is loaded when the user presses a button
import wx
import wx.xrc as xrc
app = wx.App(False)
frame = wx.Frame(None)
xrc_res = xrc.XmlResource('test.xrc')
def OnButton(evt):
dlg = xrc_res.LoadDialog(frame, 'MyDialog');
print 'adding items'
dlg.ShowModal();
button = wx.Button(frame)
button.Bind(wx.EVT_BUTTON, OnButton)
frame.Show()
app.MainLoop()
and the dialog resource contains a MyListControl of this form
import wx
class MyListCtrl(wx.ListCtrl):
def __init__(self):
pre = wx.PreListCtrl()
self.PostCreate(pre)
self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
def OnCreate(self, event):
print 'creating columns'
I would like to add items to the list's columns at the point where 'adding items' is printed.
(I can't do it in OnCreate as it needs additional information)
However, this does not work, because the EVT_WINDOW_CREATE handler is called afterwards on Linux.
So where is the place to safely add items after OnCreate?
thanks in advance...
Patrick