]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxToggleButton.py
SWIGged updates for wxMac
[wxWidgets.git] / wxPython / demo / wxToggleButton.py
1
2 from wxPython.wx import *
3
4 haveToggleBtn = 1
5 try:
6 wxToggleButton
7 except NameError:
8 haveToggleBtn = 0
9
10 #----------------------------------------------------------------------
11
12 class TestPanel(wxPanel):
13 def __init__(self, parent, log):
14 wxPanel.__init__(self, parent, -1)
15 self.log = log
16 panel = wxPanel(self, -1)
17 buttons = wxBoxSizer(wxHORIZONTAL)
18 for word in string.split("These are toggle buttons"):
19 b = wxToggleButton(panel, -1, word)
20 EVT_TOGGLEBUTTON(self, b.GetId(), self.OnToggle)
21 buttons.Add(b, flag=wxALL, border=5)
22
23 panel.SetAutoLayout(true)
24 panel.SetSizer(buttons)
25 buttons.Fit(panel)
26 panel.Move((50,50))
27
28 def OnToggle(self, evt):
29 self.log.write("Button %d toggled\n" % evt.GetId())
30
31 #----------------------------------------------------------------------
32
33 def runTest(frame, nb, log):
34 if haveToggleBtn:
35 win = TestPanel(nb, log)
36 return win
37 else:
38 dlg = wxMessageDialog(frame, 'wxToggleButton is not available on this platform.',
39 'Sorry', wxOK | wxICON_INFORMATION)
40 dlg.ShowModal()
41 dlg.Destroy()
42
43
44
45
46 #----------------------------------------------------------------------
47
48
49 overview = """\
50 """