]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxToggleButton.py
1 # 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
15 #----------------------------------------------------------------------
17 class TestPanel(wx
.Panel
):
18 def __init__(self
, parent
, log
):
19 wx
.Panel
.__init
__(self
, parent
, -1)
21 panel
= wx
.Panel(self
, -1)
22 buttons
= wx
.BoxSizer(wx
.HORIZONTAL
)
24 for word
in "These are toggle buttons".split():
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)
29 panel
.SetAutoLayout(True)
30 panel
.SetSizer(buttons
)
34 def OnToggle(self
, evt
):
35 self
.log
.write("Button %d toggled\n" % evt
.GetId())
37 #----------------------------------------------------------------------
39 def runTest(frame
, nb
, log
):
41 win
= TestPanel(nb
, log
)
44 dlg
= wx
.MessageDialog(frame
, 'wxToggleButton is not available on this platform.',
45 'Sorry', wx
.OK | wx
.ICON_INFORMATION
)
50 #----------------------------------------------------------------------
54 wxToggleButton is a button that stays pressed when clicked by the user.
55 In other words, it is similar to wxCheckBox in functionality but looks like a
58 This class is only available under wxMSW and wxGTK currently.
64 if __name__
== '__main__':
67 run
.main(['', os
.path
.basename(sys
.argv
[0])])