Hi List,
i have put a listBox Control in a wx.Frame and in a wx.Dialog. The
listbox in the wx.Frame works fine but th listbox in the wx.Dialog
select allway the last entry. I also can'd ist deselect with
'self.listBox1.Deselect(3)'. Look at the examples.
Who can help me?
File: test1.
Frame. Works fine
--->
#Boa:Frame:testFrame
import wx
def create(parent):
return testFrame(parent)
[wxID_TESTFRAME, wxID_TESTFRAMELISTBOX1,
] = [wx.NewId() for _init_ctrls in range(2)]
class testFrame(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_TESTFRAME,
name=u'testFrame',
parent=prnt, pos=wx.Point(597, 277), size=wx.Size(168,
204),
style=wx.DEFAULT_FRAME_STYLE, title=u'testFrame')
self.SetClientSize(wx.Size(168, 204))
self.Bind(wx.EVT_ACTIVATE, self.OnFrame1Activate)
self.listBox1 = wx.ListBox(choices=[],
id=wxID_TESTFRAMELISTBOX1,
name='checkListBox1', parent=self, pos=wx.Point(0, 0),
size=wx.Size(168, 204), style=wx.LB_MULTIPLE)
def __init__(self, parent):
self._init_ctrls(parent)
def OnFrame1Activate(self, event):
self.listBox1.InsertItems(['aaaa','bbbb','cccc','dddd'], 0)
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
frame = create(None)
frame.Show()
app.MainLoop(
---<
File: test2
Dialog. Works NOT fine
--->
#Boa:Dialog:testDialog
import wx
def create(parent):
return testDialog(parent)
[wxID_TESTDIALOG, wxID_TESTDIALOGLISTBOX1,
] = [wx.NewId() for _init_ctrls in range(2)]
class testDialog(wx.Dialog):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Dialog.__init__(self, id=wxID_TESTDIALOG,
name=u'testDialog',
parent=prnt, pos=wx.Point(558, 293), size=wx.Size(173,
229),
style=wx.DEFAULT_DIALOG_STYLE, title=u'TestDialog')
self.SetClientSize(wx.Size(173, 229))
self.Bind(wx.EVT_INIT_DIALOG, self.OnTestDialogInitDialog)
self.listBox1 = wx.ListBox(choices=[],
id=wxID_TESTDIALOGLISTBOX1,
name='listBox1', parent=self, pos=wx.Point(8, 8),
size=wx.Size(160, 208), style=wx.LB_MULTIPLE)
def __init__(self, parent):
self._init_ctrls(parent)
def OnTestDialogInitDialog(self, event):
self.listBox1.InsertItems(['aaaa','bbbb','cccc','dddd'], 0)
# self.listBox1.Deselect(3) # also don's work
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
dlg = create(None)
try:
dlg.ShowModal()
finally:
dlg.Destroy()
app.MainLoop()
---<