]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/ToggleButton.py
wxCheckListBox doesn't require wxUSE_OWNER_DRAWN when using WXUNIVERSAL
[wxWidgets.git] / wxPython / demo / ToggleButton.py
... / ...
CommitLineData
1
2import wx
3
4haveToggleBtn = 1
5if wx.Platform == "__WXX11__":
6 haveToggleBtn = 0
7
8#----------------------------------------------------------------------
9
10class 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
32def runTest(frame, nb, log):
33 if haveToggleBtn:
34 win = TestPanel(nb, log)
35 return win
36 else:
37 from Main import MessagePanel
38 win = MessagePanel(nb, 'wx.ToggleButton is not available on this platform.',
39 'Sorry', wx.ICON_WARNING)
40 return win
41
42
43#----------------------------------------------------------------------
44
45
46overview = """\
47wx.ToggleButton is a button that stays pressed when clicked by the user.
48In other words, it is similar to wxCheckBox in functionality but looks like a
49wxButton.
50
51This class is only available under wxMSW and wxGTK currently.
52
53"""
54
55
56
57if __name__ == '__main__':
58 import sys,os
59 import run
60 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])