]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/Choice.py
Font size adjustment
[wxWidgets.git] / wxPython / demo / Choice.py
... / ...
CommitLineData
1
2import wx
3
4#---------------------------------------------------------------------------
5
6class TestChoice(wx.Panel):
7 def __init__(self, parent, log):
8 self.log = log
9 wx.Panel.__init__(self, parent, -1)
10
11 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight']
13
14 wx.StaticText(self, -1, "This example uses the wxChoice control.", (15, 10))
15 wx.StaticText(self, -1, "Select one:", (15, 50), (75, -1))
16 self.ch = wx.Choice(self, -1, (100, 50), choices = sampleList)
17 self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch)
18
19
20 def EvtChoice(self, event):
21 self.log.WriteText('EvtChoice: %s\n' % event.GetString())
22 self.ch.Append("A new item")
23
24 if event.GetString() == 'one':
25 self.log.WriteText('Well done!\n')
26
27
28#---------------------------------------------------------------------------
29
30def runTest(frame, nb, log):
31 win = TestChoice(nb, log)
32 return win
33
34#---------------------------------------------------------------------------
35
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.
40
41This demo illustrates how to set up the Choice control and how to extract the
42selected choice once it is selected.
43
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>.
47"""
48
49
50if __name__ == '__main__':
51 import sys,os
52 import run
53 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
54