2 from wxPython
.wx
import *
4 #---------------------------------------------------------------------------
11 class TestRadioButtons(wxPanel
):
12 def __init__(self
, parent
, log
):
14 wxPanel
.__init
__(self
, parent
, -1)
15 #self.SetBackgroundColour(wxBLUE)
17 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
18 'six', 'seven', 'eight']
20 sizer
= wxBoxSizer(wxVERTICAL
)
21 rb
= wxRadioBox(self
, RBOX1
, "wxRadioBox",
22 wxDefaultPosition
, wxDefaultSize
,
23 sampleList
, 2, wxRA_SPECIFY_COLS
)
24 EVT_RADIOBOX(self
, RBOX1
, self
.EvtRadioBox
)
25 #rb.SetBackgroundColour(wxBLUE)
26 rb
.SetToolTip(wxToolTip("This is a ToolTip!"))
27 #rb.SetLabel("wxRadioBox")
28 sizer
.Add(rb
, 0, wxALL
, 20)
30 rb
= wxRadioBox(self
, RBOX2
, "", wxDefaultPosition
, wxDefaultSize
,
31 sampleList
, 3, wxRA_SPECIFY_COLS | wxNO_BORDER
)
32 EVT_RADIOBOX(self
, RBOX2
, self
.EvtRadioBox
)
33 rb
.SetToolTip(wxToolTip("This box has no label"))
34 sizer
.Add(rb
, 0, wxLEFT|wxRIGHT|wxBOTTOM
, 20)
36 sizer
.Add(wxStaticText(self
, -1, "These are plain wxRadioButtons"),
37 0, wxLEFT|wxRIGHT
, 20)
38 sizer
.Add(wxRadioButton(self
, RBUT1
, "wxRadioButton 1"),
39 0, wxLEFT|wxRIGHT
, 20)
40 sizer
.Add(wxRadioButton(self
, RBUT2
, "wxRadioButton 2"),
41 0, wxLEFT|wxRIGHT
, 20)
42 EVT_RADIOBUTTON(self
, RBUT1
, self
.EvtRadioButton
)
43 EVT_RADIOBUTTON(self
, RBUT2
, self
.EvtRadioButton
)
48 def EvtRadioBox(self
, event
):
49 self
.log
.WriteText('EvtRadioBox: %d\n' % event
.GetInt())
51 def EvtRadioButton(self
, event
):
52 self
.log
.write('EvtRadioButton:%d\n' % event
.GetInt())
54 #---------------------------------------------------------------------------
56 def runTest(frame
, nb
, log
):
57 win
= TestRadioButtons(nb
, log
)
60 #---------------------------------------------------------------------------
73 A radio box item is used to select one of number of mutually exclusive choices. It is displayed as a vertical column or horizontal row of labelled buttons.