Hi Kamil,
Hello everybody,
I found very strange thing. In my app there is radio box with two radio buttons and menu bar. See example below. (Adding some menus to menu bar doesn't change aplication behaviour, so I ommited them in the example)
The problem is, that if I run attached program as is and click on radio box's buttons OnRadioBox1Radiobox() handler is not called. If I change sellection using arrows it is called properly.
Then if I disalble MenuBar by commenting indicated line everything works fine (handler is called after clicking and after changing using arrows).
What is going on?
Regards,
Kamilimport wx
[wxID_FRAME2, wxID_FRAME2RADIOBOX1, ] = [wx.NewId() for _init_ctrls in range(2)]
class MyFrame(wx.Frame):
def __init__(self, prnt):
wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prnt,
style=wx.DEFAULT_FRAME_STYLE, title='Test')
self.menuBar1 = wx.MenuBar()
self.menuBar1.SetClientSize(wx.Size(58199472, -1))#
# disabling next line will cause OnRadioBox1Radiobox() to be called properly
#
self.SetMenuBar(self.menuBar1)self.radioBox1 = wx.RadioBox(choices=['one', 'two'],
id=wxID_FRAME2RADIOBOX1, label='radioBox1', majorDimension=1,
name='radioBox1', parent=self, pos=wx.Point(88, 80),
size=wx.Size(208, 104), style=wx.RA_SPECIFY_COLS)
self.radioBox1.Bind(wx.EVT_RADIOBOX, self.OnRadioBox1Radiobox,
id=wxID_FRAME2RADIOBOX1)def OnRadioBox1Radiobox(self, event):
print "OnRadioBox1Radiobox()\n"if __name__ == '__main__':
app = wx.PySimpleApp()
mf = MyFrame(None)
mf.Show()
app.MainLoop()
The problem is that the parent for your RadioBox should be a wx.Panel. Try doing something like this right after :
wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prnt,
style=wx.DEFAULT_FRAME_STYLE, title='Test')
panel = wx.Panel(self, wx.ID_ANY)
And then change the RadioBox's initialization like so:
self.radioBox1 = wx.RadioBox(panel, choices=['one', 'two'],
id=wxID_FRAME2RADIOBOX1, label='radioBox1', majorDimension=1,
name='radioBox1', pos=wx.Point(88, 80),
size=wx.Size(208, 104), style=wx.RA_SPECIFY_COLS)
This works for me on Windows XP. Plus if you use panels, it will look consistent on a cross-platform basis. If you don't, then it looks kind of weird on Windows.
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org