]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Choice.py
wxUSE_STL/wxArrayString fixes.
[wxWidgets.git] / wxPython / demo / Choice.py
CommitLineData
cf694132 1
8fa876ca 2import wx
cf694132
RD
3
4#---------------------------------------------------------------------------
5
8fa876ca 6class TestChoice(wx.Panel):
cf694132
RD
7 def __init__(self, parent, log):
8 self.log = log
8fa876ca 9 wx.Panel.__init__(self, parent, -1)
cf694132
RD
10
11 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight']
13
8fa876ca 14 wx.StaticText(self, -1, "This example uses the wxChoice control.", (15, 10))
10b12f71
RD
15 wx.StaticText(self, -1, "Select one:", (15, 50), (75, -1))
16 self.ch = wx.Choice(self, -1, (100, 50), choices = sampleList)
8fa876ca 17 self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch)
cf694132 18
d56cebe7 19
cf694132
RD
20 def EvtChoice(self, event):
21 self.log.WriteText('EvtChoice: %s\n' % event.GetString())
d56cebe7 22 self.ch.Append("A new item")
8fa876ca
RD
23
24 if event.GetString() == 'one':
25 self.log.WriteText('Well done!\n')
d56cebe7 26
cf694132
RD
27
28#---------------------------------------------------------------------------
29
30def runTest(frame, nb, log):
31 win = TestChoice(nb, log)
32 return win
33
34#---------------------------------------------------------------------------
35
8fa876ca
RD
36overview = """
37A Choice control is used to select one of a list of strings. Unlike a listbox,
38only the current selection is visible until the user pulls down the menu of
39choices.
cf694132 40
8fa876ca
RD
41This demo illustrates how to set up the Choice control and how to extract the
42selected choice once it is selected.
cf694132 43
8fa876ca
RD
44Note that the syntax of the constructor is different than the C++ implementation.
45The number of choices and the choice array are consilidated into one python
46<code>list</code>.
cf694132 47"""
1fded56b
RD
48
49
1fded56b
RD
50if __name__ == '__main__':
51 import sys,os
52 import run
8eca4fef 53 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1fded56b 54