2001-05-06 05:03:24 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
2001-05-06 05:03:24 +00:00
|
|
|
|
2002-08-13 23:59:08 +00:00
|
|
|
haveToggleBtn = 1
|
2004-02-23 21:23:26 +00:00
|
|
|
if wx.Platform == "__WXX11__":
|
2002-08-13 23:59:08 +00:00
|
|
|
haveToggleBtn = 0
|
|
|
|
|
2001-05-06 05:03:24 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
2001-05-06 05:03:24 +00:00
|
|
|
def __init__(self, parent, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
2001-05-06 05:03:24 +00:00
|
|
|
self.log = log
|
2003-12-09 01:23:28 +00:00
|
|
|
panel = wx.Panel(self, -1)
|
|
|
|
buttons = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
for word in "These are toggle buttons".split():
|
2003-12-09 01:23:28 +00: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 05:03:24 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
panel.SetAutoLayout(True)
|
2001-05-06 05:03:24 +00: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 23:59:08 +00:00
|
|
|
if haveToggleBtn:
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
else:
|
2004-11-01 19:39:09 +00:00
|
|
|
from Main import MessagePanel
|
|
|
|
win = MessagePanel(nb, 'wx.ToggleButton is not available on this platform.',
|
|
|
|
'Sorry', wx.ICON_WARNING)
|
|
|
|
return win
|
2002-08-13 23:59:08 +00:00
|
|
|
|
|
|
|
|
2001-05-06 05:03:24 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
2004-01-13 03:17:17 +00:00
|
|
|
wx.ToggleButton is a button that stays pressed when clicked by the user.
|
2003-12-09 01:23:28 +00:00
|
|
|
In other words, it is similar to wxCheckBox in functionality but looks like a
|
|
|
|
wxButton.
|
2003-07-02 23:13:10 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
This class is only available under wxMSW and wxGTK currently.
|
2003-07-02 23:13:10 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
"""
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|