]> git.saurik.com Git - wxWidgets.git/blame - wxPython/samples/wxPIA_book/Chapter-10/with_accelerator.py
use textures in the shared context to test how this works when using multiple windows...
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-10 / with_accelerator.py
CommitLineData
be05b434
RD
1import wx
2
3class MyFrame(wx.Frame):
4 def __init__(self):
5 wx.Frame.__init__(self, None, -1,
6 "Accelerator Example")
7 p = wx.Panel(self)
8 menu = wx.Menu()
9 simple = menu.Append(-1, "Simple &menu item") # with mnemonic
10 accel = menu.Append(-1, "&Accelerated\tCtrl-A") # with accelerator
11
12 menu.AppendSeparator()
13 exit = menu.Append(-1, "E&xit")
14
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)
18
19 menuBar = wx.MenuBar()
20 menuBar.Append(menu, "&Menu")
21 self.SetMenuBar(menuBar)
22
23 # An alternate way to make accelerators
24 acceltbl = wx.AcceleratorTable( [
25 (wx.ACCEL_CTRL, ord('Q'), exit.GetId())
26 ])
27 self.SetAcceleratorTable(acceltbl)
28
29
30 def OnSimple(self, event):
31 wx.MessageBox("You selected the simple menu item")
32
33 def OnAccelerated(self, event):
34 wx.MessageBox("You selected the accelerated menu item")
35
36
37 def OnExit(self, event):
38 self.Close()
39
40
41if __name__ == "__main__":
42 app = wx.PySimpleApp()
43 frame = MyFrame()
44 frame.Show()
45 app.MainLoop()
46
47