I want to create a comboctrl with a listbox as the popup widget. The
problem is with the class MyPopup that derives from wx.ListBox and
wx.combo.ComboPopup. When running the code I get the following
exception :
TypeError: in method 'ComboPopup__setCallbackInfo', expected argument
1 of type 'wxPyComboPopup *'
the problem seems to be this line in the class MyPopup:
self.PostCreate(wx.PreListBox())
I'm pretty new to wxPython and python (but loving it!) so it is
probably something obvious that I am missing.
Here is the sample code :
### Sample code demonstrating the problem
# -*- coding: latin-1 -*-
import wx
import wx.combo
class TestApp(wx.App):
def OnInit(self):
frmConsultation = wx.Frame(None, size=(200, -1))
cb = wx.combo.ComboCtrl(frmConsultation, -1)
cb.SetPopupMaxHeight(150)
# popup = ListBoxComboPopup() # This line works
popup = MyPopup() # This one causes the problem
cb.SetPopupControl(popup)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(cb, 0, wx.EXPAND)
frmConsultation.SetSizer(sizer)
frmConsultation.SetAutoLayout(True)
sizer.Fit(frmConsultation)
frmConsultation.Show(True)
self.SetTopWindow(frmConsultation)
return True
class ListBoxComboPopup(wx.combo.ComboPopup):
def Create(self, parent):
print 'create'
self.list = wx.ListBox(parent)
return True
def GetControl(self):
return self.list
class MyPopup(wx.ListBox, wx.combo.ComboPopup):
def __init__(self, *args, **kwargs):
self.PostCreate(wx.PreListBox())
wx.combo.ComboPopup.__init__(self)
def Create(self, parent):
wx.ListBox.Create(self, parent)
return True
def GetControl(self):
return self
app = TestApp(0)
app.MainLoop()
### End of sample code
Fred