]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-10/with_accelerator.py
3 class MyFrame(wx
.Frame
):
5 wx
.Frame
.__init
__(self
, None, -1,
9 simple
= menu
.Append(-1, "Simple &menu item") # with mnemonic
10 accel
= menu
.Append(-1, "&Accelerated\tCtrl-A") # with accelerator
12 menu
.AppendSeparator()
13 exit
= menu
.Append(-1, "E&xit")
15 self
.Bind(wx
.EVT_MENU
, self
.OnSimple
, simple
)
16 self
.Bind(wx
.EVT_MENU
, self
.OnAccelerated
, accel
)
17 self
.Bind(wx
.EVT_MENU
, self
.OnExit
, exit
)
19 menuBar
= wx
.MenuBar()
20 menuBar
.Append(menu
, "&Menu")
21 self
.SetMenuBar(menuBar
)
23 # An alternate way to make accelerators
24 acceltbl
= wx
.AcceleratorTable( [
25 (wx
.ACCEL_CTRL
, ord('Q'), exit
.GetId())
27 self
.SetAcceleratorTable(acceltbl
)
30 def OnSimple(self
, event
):
31 wx
.MessageBox("You selected the simple menu item")
33 def OnAccelerated(self
, event
):
34 wx
.MessageBox("You selected the accelerated menu item")
37 def OnExit(self
, event
):
41 if __name__
== "__main__":
42 app
= wx
.PySimpleApp()