]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/CheckBox.py
'[1219035] cleanup: miscellaneous' and minor source cleaning.
[wxWidgets.git] / wxPython / demo / CheckBox.py
CommitLineData
cf694132 1
8fa876ca 2import wx
cf694132
RD
3
4#---------------------------------------------------------------------------
5
8fa876ca 6class TestCheckBox(wx.Panel):
cf694132
RD
7 def __init__(self, parent, log):
8 self.log = log
8fa876ca 9 wx.Panel.__init__(self, parent, -1)
cf694132 10
167ad3b2 11 st = wx.StaticText(self, -1, "This example demonstrates the wx.CheckBox control.")#, (10, 10))
cf694132 12
167ad3b2
RD
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)
1e4a197e 15 cb2.SetValue(True)
167ad3b2
RD
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
cf694132 22
8fa876ca
RD
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)
167ad3b2
RD
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
cf694132
RD
44
45 def EvtCheckBox(self, event):
167ad3b2
RD
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
cf694132
RD
51
52#---------------------------------------------------------------------------
53
54def runTest(frame, nb, log):
55 win = TestCheckBox(nb, log)
56 return win
57
58#---------------------------------------------------------------------------
59
60
cf694132 61overview = """\
95bfd958
RD
62A checkbox is a labelled box which is either on (checkmark is visible) or off
63(no checkmark).
cf694132 64
cf694132 65"""
1fded56b 66
95bfd958 67#---------------------------------------------------------------------------
1fded56b
RD
68
69if __name__ == '__main__':
70 import sys,os
71 import run
8eca4fef 72 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1fded56b 73