]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/RadioBox.py
Set the DC font before drawing the label
[wxWidgets.git] / wxPython / demo / RadioBox.py
1 # 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 #
5
6 import wx
7
8 #---------------------------------------------------------------------------
9
10 class TestRadioBox(wx.Panel):
11 def __init__(self, parent, log):
12 self.log = log
13 wx.Panel.__init__(self, parent, -1)
14 #self.SetBackgroundColour(wx.BLUE)
15
16 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
17 'six', 'seven', 'eight']
18
19 sizer = wx.BoxSizer(wx.VERTICAL)
20
21 rb = wx.RadioBox(
22 self, -1, "wx.RadioBox", wx.DefaultPosition, wx.DefaultSize,
23 sampleList, 2, wx.RA_SPECIFY_COLS
24 )
25
26 self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb)
27 #rb.SetBackgroundColour(wx.BLUE)
28 rb.SetToolTip(wx.ToolTip("This is a ToolTip!"))
29 #rb.SetLabel("wxRadioBox")
30
31 sizer.Add(rb, 0, wx.ALL, 20)
32
33 rb = wx.RadioBox(
34 self, -1, "", wx.DefaultPosition, wx.DefaultSize,
35 sampleList, 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER
36 )
37
38 self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb)
39 rb.SetToolTip(wx.ToolTip("This box has no label"))
40
41 sizer.Add(rb, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 20)
42
43 self.SetSizer(sizer)
44
45
46 def EvtRadioBox(self, event):
47 self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt())
48
49 # Doesn't appear to be used for anything.
50 # def EvtRadioButton(self, event):
51 # self.log.write('EvtRadioButton:%d\n' % event.GetId())
52
53 #---------------------------------------------------------------------------
54
55 def runTest(frame, nb, log):
56 win = TestRadioBox(nb, log)
57 return win
58
59
60
61 overview = """\
62 A radio box item is used to select one of number of mutually exclusive
63 choices. It is displayed as a vertical column or horizontal row of
64 labelled buttons.
65
66 """
67
68
69 if __name__ == '__main__':
70 import sys,os
71 import run
72 run.main(['', os.path.basename(sys.argv[0])])
73