]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-10/disable_item.py
5 class MyFrame(wx
.Frame
):
7 wx
.Frame
.__init
__(self
, None, -1,
8 "Enable/Disable Menu Example")
10 self
.btn
= wx
.Button(p
, -1, "Disable Item", (20,20))
11 self
.Bind(wx
.EVT_BUTTON
, self
.OnToggleItem
, self
.btn
)
14 menu
.Append(ID_SIMPLE
, "Simple menu item")
15 self
.Bind(wx
.EVT_MENU
, self
.OnSimple
, id=ID_SIMPLE
)
17 menu
.AppendSeparator()
18 menu
.Append(wx
.ID_EXIT
, "Exit")
19 self
.Bind(wx
.EVT_MENU
, self
.OnExit
, id=wx
.ID_EXIT
)
21 menuBar
= wx
.MenuBar()
22 menuBar
.Append(menu
, "Menu")
23 self
.SetMenuBar(menuBar
)
26 def OnSimple(self
, event
):
27 wx
.MessageBox("You selected the simple menu item")
29 def OnExit(self
, event
):
32 def OnToggleItem(self
, event
):
33 menubar
= self
.GetMenuBar()
34 enabled
= menubar
.IsEnabled(ID_SIMPLE
)
35 menubar
.Enable(ID_SIMPLE
, not enabled
)
37 (enabled
and "Enable" or "Disable") + " Item")
40 if __name__
== "__main__":
41 app
= wx
.PySimpleApp()