]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | import wx | |
3 | ||
4 | haveToggleBtn = 1 | |
5 | if wx.Platform == "__WXX11__": | |
6 | haveToggleBtn = 0 | |
7 | ||
8 | #---------------------------------------------------------------------- | |
9 | ||
10 | class TestPanel(wx.Panel): | |
11 | def __init__(self, parent, log): | |
12 | wx.Panel.__init__(self, parent, -1) | |
13 | self.log = log | |
14 | panel = wx.Panel(self, -1) | |
15 | buttons = wx.BoxSizer(wx.HORIZONTAL) | |
16 | ||
17 | for word in "These are toggle buttons".split(): | |
18 | b = wx.ToggleButton(panel, -1, word) | |
19 | self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b) | |
20 | buttons.Add(b, flag=wx.ALL, border=5) | |
21 | ||
22 | panel.SetAutoLayout(True) | |
23 | panel.SetSizer(buttons) | |
24 | buttons.Fit(panel) | |
25 | panel.Move((50,50)) | |
26 | ||
27 | def OnToggle(self, evt): | |
28 | self.log.write("Button %d toggled\n" % evt.GetId()) | |
29 | ||
30 | #---------------------------------------------------------------------- | |
31 | ||
32 | def runTest(frame, nb, log): | |
33 | if haveToggleBtn: | |
34 | win = TestPanel(nb, log) | |
35 | return win | |
36 | else: | |
37 | dlg = wx.MessageDialog(frame, 'wx.ToggleButton is not available on this platform.', | |
38 | 'Sorry', wx.OK | wx.ICON_INFORMATION) | |
39 | dlg.ShowModal() | |
40 | dlg.Destroy() | |
41 | ||
42 | ||
43 | #---------------------------------------------------------------------- | |
44 | ||
45 | ||
46 | overview = """\ | |
47 | wx.ToggleButton is a button that stays pressed when clicked by the user. | |
48 | In other words, it is similar to wxCheckBox in functionality but looks like a | |
49 | wxButton. | |
50 | ||
51 | This class is only available under wxMSW and wxGTK currently. | |
52 | ||
53 | """ | |
54 | ||
55 | ||
56 | ||
57 | if __name__ == '__main__': | |
58 | import sys,os | |
59 | import run | |
60 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |