]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/CheckBox.py
wxUSE_*BOOK checks.
[wxWidgets.git] / wxPython / demo / CheckBox.py
1
2 import wx
3
4 #---------------------------------------------------------------------------
5
6 class TestCheckBox(wx.Panel):
7 def __init__(self, parent, log):
8 self.log = log
9 wx.Panel.__init__(self, parent, -1)
10
11 st = wx.StaticText(self, -1, "This example demonstrates the wx.CheckBox control.")#, (10, 10))
12
13 cb1 = wx.CheckBox(self, -1, "Apples")#, (65, 40), (150, 20), wx.NO_BORDER)
14 cb2 = wx.CheckBox(self, -1, "Oranges")#, (65, 60), (150, 20), wx.NO_BORDER)
15 cb2.SetValue(True)
16 cb3 = wx.CheckBox(self, -1, "Pears")#, (65, 80), (150, 20), wx.NO_BORDER)
17
18 cb4 = wx.CheckBox(self, -1, "3-state checkbox",
19 style=wx.CHK_3STATE|wx.CHK_ALLOW_3RD_STATE_FOR_USER)
20 cb5 = wx.CheckBox(self, -1, "Align Right", style=wx.ALIGN_RIGHT)
21
22
23 self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb1)
24 self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb2)
25 self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb3)
26 self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb4)
27 self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb5)
28
29 sizer = wx.BoxSizer(wx.VERTICAL)
30 sizer.AddMany( [ cb1,
31 cb2,
32 cb3,
33 (20,20),
34 cb4,
35 (20,20),
36 cb5
37 ])
38
39 border = wx.BoxSizer(wx.VERTICAL)
40 border.Add(st, 0, wx.ALL, 15)
41 border.Add(sizer, 0, wx.LEFT, 50)
42 self.SetSizer(border)
43
44
45 def EvtCheckBox(self, event):
46 self.log.write('EvtCheckBox: %d\n' % event.IsChecked())
47 cb = event.GetEventObject()
48 if cb.Is3State():
49 self.log.write("\t3StateValue: %s\n" % cb.Get3StateValue())
50
51
52 #---------------------------------------------------------------------------
53
54 def runTest(frame, nb, log):
55 win = TestCheckBox(nb, log)
56 return win
57
58 #---------------------------------------------------------------------------
59
60
61 overview = """\
62 A checkbox is a labelled box which is either on (checkmark is visible) or off
63 (no checkmark).
64
65 """
66
67 #---------------------------------------------------------------------------
68
69 if __name__ == '__main__':
70 import sys,os
71 import run
72 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
73