- Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathButtonArray.py
More file actions
Latest commit
executable file
·55 lines (31 loc) · 1.15 KB
/
Copy pathButtonArray.py
File metadata and controls
executable file
·55 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
importwx
classButtonArrayPanel(wx.Panel):
def__init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
Sizer=wx.GridSizer(16, 2, 0, 0)
foriinrange(32):
B=wx.Button(self, label="button %i"%i)
B.Bind(wx.EVT_BUTTON,
lambdaevt, but_num=i: self.OnButton(evt, but_num) )
Sizer.Add(B, 0, wx.GROW|wx.ALL, 4)
self.SetSizerAndFit(Sizer)
defOnButton(self, evt, but_num):
print"Button number: %i clicked"%but_num
classDemoFrame(wx.Frame):
def__init__(self, title="Button Array Demo"):
wx.Frame.__init__(self, None , -1, title)
btn=wx.Button(self, label="Quit")
btn.Bind(wx.EVT_BUTTON, self.OnQuit )
BP=ButtonArrayPanel(self)
Sizer=wx.BoxSizer(wx.VERTICAL)
Sizer.Add(btn, 1, wx.CENTER|wx.ALL, 6)
Sizer.Add(BP, 0, wx.CENTER|wx.ALL, 4)
self.SetSizerAndFit(Sizer)
self.Bind(wx.EVT_CLOSE, self.OnQuit)
defOnQuit(self,Event):
self.Destroy()
app=wx.App(False)
frame=DemoFrame()
frame.Show()
app.MainLoop()