]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxToggleButton.py
reSWIGged
[wxWidgets.git] / wxPython / demo / wxToggleButton.py
CommitLineData
8fa876ca
RD
1# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4#
d1679124 5
8fa876ca 6import wx
d1679124 7
eb0f373c 8haveToggleBtn = 1
8fa876ca 9
eb0f373c 10try:
8fa876ca 11 wx.ToggleButton
eb0f373c
RD
12except NameError:
13 haveToggleBtn = 0
14
d1679124
RD
15#----------------------------------------------------------------------
16
8fa876ca 17class TestPanel(wx.Panel):
d1679124 18 def __init__(self, parent, log):
8fa876ca 19 wx.Panel.__init__(self, parent, -1)
d1679124 20 self.log = log
8fa876ca
RD
21 panel = wx.Panel(self, -1)
22 buttons = wx.BoxSizer(wx.HORIZONTAL)
23
1e4a197e 24 for word in "These are toggle buttons".split():
8fa876ca
RD
25 b = wx.ToggleButton(panel, -1, word)
26 self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b)
27 buttons.Add(b, flag=wx.ALL, border=5)
d1679124 28
1e4a197e 29 panel.SetAutoLayout(True)
d1679124
RD
30 panel.SetSizer(buttons)
31 buttons.Fit(panel)
32 panel.Move((50,50))
33
34 def OnToggle(self, evt):
35 self.log.write("Button %d toggled\n" % evt.GetId())
36
37#----------------------------------------------------------------------
38
39def runTest(frame, nb, log):
eb0f373c
RD
40 if haveToggleBtn:
41 win = TestPanel(nb, log)
42 return win
43 else:
8fa876ca
RD
44 dlg = wx.MessageDialog(frame, 'wxToggleButton is not available on this platform.',
45 'Sorry', wx.OK | wx.ICON_INFORMATION)
eb0f373c
RD
46 dlg.ShowModal()
47 dlg.Destroy()
48
49
d1679124
RD
50#----------------------------------------------------------------------
51
52
53overview = """\
8fa876ca
RD
54wxToggleButton is a button that stays pressed when clicked by the user.
55In other words, it is similar to wxCheckBox in functionality but looks like a
56wxButton.
1fded56b 57
8fa876ca 58This class is only available under wxMSW and wxGTK currently.
1fded56b 59
8fa876ca 60"""
1fded56b
RD
61
62
63
64if __name__ == '__main__':
65 import sys,os
66 import run
67 run.main(['', os.path.basename(sys.argv[0])])