]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-10/update_ui.py
5 class MyFrame(wx
.Frame
):
7 wx
.Frame
.__init
__(self
, None, -1,
8 "UPDATE_UI 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")
16 self
.Bind(wx
.EVT_MENU
, self
.OnSimple
, id=ID_SIMPLE
)
17 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateSimple
, id=ID_SIMPLE
)
19 menu
.AppendSeparator()
20 menu
.Append(wx
.ID_EXIT
, "Exit")
21 self
.Bind(wx
.EVT_MENU
, self
.OnExit
, id=wx
.ID_EXIT
)
23 menuBar
= wx
.MenuBar()
24 menuBar
.Append(menu
, "Menu")
25 self
.SetMenuBar(menuBar
)
28 def OnSimple(self
, event
):
29 wx
.MessageBox("You selected the simple menu item")
31 def OnExit(self
, event
):
34 def OnToggleItem(self
, event
):
36 (self
.enabled
and "Enable" or "Disable") + " Item")
37 self
.enabled
= not self
.enabled
39 def OnUpdateSimple(self
, event
):
40 event
.Enable(self
.enabled
)
43 if __name__
== "__main__":
44 app
= wx
.PySimpleApp()