3 class RadioButtonFrame(wx
.Frame
):
5 wx
.Frame
.__init
__(self
, None, -1, 'Radio Example',
7 panel
= wx
.Panel(self
, -1)
8 radio1
= wx
.RadioButton(panel
, -1, "Elmo", pos
=(20, 50), style
=wx
.RB_GROUP
)
9 radio2
= wx
.RadioButton(panel
, -1, "Ernie", pos
=(20, 80))
10 radio3
= wx
.RadioButton(panel
, -1, "Bert", pos
=(20, 110))
11 text1
= wx
.TextCtrl(panel
, -1, "", pos
=(80, 50))
12 text2
= wx
.TextCtrl(panel
, -1, "", pos
=(80, 80))
13 text3
= wx
.TextCtrl(panel
, -1, "", pos
=(80, 110))
14 self
.texts
= {"Elmo": text1, "Ernie": text2, "Bert": text3}
15 for eachText
in [text2
, text3
]:
16 eachText
.Enable(False)
17 for eachRadio
in [radio1
, radio2
, radio3
]:
18 self
.Bind(wx
.EVT_RADIOBUTTON
, self
.OnRadio
, eachRadio
)
19 self
.selectedText
= text1
21 def OnRadio(self
, event
):
23 self
.selectedText
.Enable(False)
24 radioSelected
= event
.GetEventObject()
25 text
= self
.texts
[radioSelected
.GetLabel()]
27 self
.selectedText
= text
29 if __name__
== '__main__':
30 app
= wx
.PySimpleApp()
31 RadioButtonFrame().Show()