2 from wxPython
.wx
import *
4 #---------------------------------------------------------------------------
6 class TestChoice(wxPanel
):
7 def __init__(self
, parent
, log
):
9 wxPanel
.__init
__(self
, parent
, -1)
11 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight']
14 wxStaticText(self
, -1, "This example uses the wxChoice control.",
17 wxStaticText(self
, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
18 self
.ch
= wxChoice(self
, 40, (80, 50), choices
= sampleList
)
19 EVT_CHOICE(self
, 40, self
.EvtChoice
)
22 def EvtChoice(self
, event
):
23 self
.log
.WriteText('EvtChoice: %s\n' % event
.GetString())
24 self
.ch
.Append("A new item")
27 #---------------------------------------------------------------------------
29 def runTest(frame
, nb
, log
):
30 win
= TestChoice(nb
, log
)
33 #---------------------------------------------------------------------------
47 A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices.
54 if __name__
== '__main__':
57 run
.main(['', os
.path
.basename(sys
.argv
[0])])