2001-05-06 01:03:24 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
2001-05-06 01:03:24 -04:00
|
|
|
|
2002-08-13 19:59:08 -04:00
|
|
|
haveToggleBtn = 1
|
2004-02-23 16:23:26 -05:00
|
|
|
if wx.Platform == "__WXX11__":
|
2002-08-13 19:59:08 -04:00
|
|
|
haveToggleBtn = 0
|
|
|
|
|
2001-05-06 01:03:24 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestPanel(wx.Panel):
|
2001-05-06 01:03:24 -04:00
|
|
|
def __init__(self, parent, log):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
2001-05-06 01:03:24 -04:00
|
|
|
self.log = log
|
2003-12-08 20:23:28 -05:00
|
|
|
panel = wx.Panel(self, -1)
|
|
|
|
buttons = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
for word in "These are toggle buttons".split():
|
2003-12-08 20:23:28 -05:00
|
|
|
b = wx.ToggleButton(panel, -1, word)
|
|
|
|
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b)
|
|
|
|
buttons.Add(b, flag=wx.ALL, border=5)
|
2001-05-06 01:03:24 -04:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
panel.SetAutoLayout(True)
|
2001-05-06 01:03:24 -04:00
|
|
|
panel.SetSizer(buttons)
|
|
|
|
buttons.Fit(panel)
|
|
|
|
panel.Move((50,50))
|
|
|
|
|
|
|
|
def OnToggle(self, evt):
|
|
|
|
self.log.write("Button %d toggled\n" % evt.GetId())
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2002-08-13 19:59:08 -04:00
|
|
|
if haveToggleBtn:
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
else:
|
2004-01-12 22:17:17 -05:00
|
|
|
dlg = wx.MessageDialog(frame, 'wx.ToggleButton is not available on this platform.',
|
2003-12-08 20:23:28 -05:00
|
|
|
'Sorry', wx.OK | wx.ICON_INFORMATION)
|
2002-08-13 19:59:08 -04:00
|
|
|
dlg.ShowModal()
|
|
|
|
dlg.Destroy()
|
|
|
|
|
|
|
|
|
2001-05-06 01:03:24 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
2004-01-12 22:17:17 -05:00
|
|
|
wx.ToggleButton is a button that stays pressed when clicked by the user.
|
2003-12-08 20:23:28 -05:00
|
|
|
In other words, it is similar to wxCheckBox in functionality but looks like a
|
|
|
|
wxButton.
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
This class is only available under wxMSW and wxGTK currently.
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
"""
|
2003-07-02 19:13:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|