]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxChoice.py
1 # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
8 #---------------------------------------------------------------------------
10 class TestChoice(wx
.Panel
):
11 def __init__(self
, parent
, log
):
13 wx
.Panel
.__init
__(self
, parent
, -1)
15 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
16 'six', 'seven', 'eight']
18 wx
.StaticText(self
, -1, "This example uses the wxChoice control.", (15, 10))
19 wx
.StaticText(self
, -1, "Select one:", (15, 50), (75, 20))
20 self
.ch
= wx
.Choice(self
, -1, (80, 50), choices
= sampleList
)
21 self
.Bind(wx
.EVT_CHOICE
, self
.EvtChoice
, self
.ch
)
24 def EvtChoice(self
, event
):
25 self
.log
.WriteText('EvtChoice: %s\n' % event
.GetString())
26 self
.ch
.Append("A new item")
28 if event
.GetString() == 'one':
29 self
.log
.WriteText('Well done!\n')
32 #---------------------------------------------------------------------------
34 def runTest(frame
, nb
, log
):
35 win
= TestChoice(nb
, log
)
38 #---------------------------------------------------------------------------
41 A Choice control is used to select one of a list of strings. Unlike a listbox,
42 only the current selection is visible until the user pulls down the menu of
45 This demo illustrates how to set up the Choice control and how to extract the
46 selected choice once it is selected.
48 Note that the syntax of the constructor is different than the C++ implementation.
49 The number of choices and the choice array are consilidated into one python
56 if __name__
== '__main__':
59 run
.main(['', os
.path
.basename(sys
.argv
[0])])