]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/Choice.py
doc tweaks, typo fixed, etc.
[wxWidgets.git] / wxPython / demo / Choice.py
... / ...
CommitLineData
1# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4#
5
6import wx
7
8#---------------------------------------------------------------------------
9
10class TestChoice(wx.Panel):
11 def __init__(self, parent, log):
12 self.log = log
13 wx.Panel.__init__(self, parent, -1)
14
15 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
16 'six', 'seven', 'eight']
17
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)
22
23
24 def EvtChoice(self, event):
25 self.log.WriteText('EvtChoice: %s\n' % event.GetString())
26 self.ch.Append("A new item")
27
28 if event.GetString() == 'one':
29 self.log.WriteText('Well done!\n')
30
31
32#---------------------------------------------------------------------------
33
34def runTest(frame, nb, log):
35 win = TestChoice(nb, log)
36 return win
37
38#---------------------------------------------------------------------------
39
40overview = """
41A Choice control is used to select one of a list of strings. Unlike a listbox,
42only the current selection is visible until the user pulls down the menu of
43choices.
44
45This demo illustrates how to set up the Choice control and how to extract the
46selected choice once it is selected.
47
48Note that the syntax of the constructor is different than the C++ implementation.
49The number of choices and the choice array are consilidated into one python
50<code>list</code>.
51"""
52
53
54
55
56if __name__ == '__main__':
57 import sys,os
58 import run
59 run.main(['', os.path.basename(sys.argv[0])])
60