I can't figure out how to set a radio button within a filemenu. I can use myRadioButton.SetValue( True ) outside of a filemenu.
What I'm trying to do is to automatically set a particular radio button dependent upon the last value used.
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
# Menu Bar
self.frame_1_menubar = wx.MenuBar()
self.name = wx.Menu()
self.one = wx.MenuItem(self.name, 101, "one", "", wx.ITEM_RADIO)
self.name.AppendItem(self.one)
self.two = wx.MenuItem(self.name, 102, "two", "", wx.ITEM_RADIO)
self.name.AppendItem(self.two)
self.three = wx.MenuItem(self.name, 103, "three", "", wx.ITEM_RADIO)
self.name.AppendItem(self.three)
self.frame_1_menubar.Append(self.name, "time out")
self.SetMenuBar(self.frame_1_menubar)
# Menu Bar end
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_MENU, self.on_one, self.one)
self.Bind(wx.EVT_MENU, self.on_two, self.two)
self.Bind(wx.EVT_MENU, self.on_three, self.three)
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade
def on_three(self, event): # wxGlade: MyFrame.<event_handler>
print "Event handler `on_three' not implemented!"
event.Skip()
def on_two(self, event): # wxGlade: MyFrame.<event_handler>
print "Event handler `on_two' not implemented!"
event.Skip()
def on_one( self, event): # wxGlade: MyFrame.<event_handler>
print "Event handler `on_four' not implemented!"
event.Skip()
# end of class MyFrame
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()