]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Choice.py
Renamed demo modules to be wx-less.
[wxWidgets.git] / wxPython / demo / Choice.py
1 # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 #
5
6 import wx
7
8 #---------------------------------------------------------------------------
9
10 class 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
34 def runTest(frame, nb, log):
35 win = TestChoice(nb, log)
36 return win
37
38 #---------------------------------------------------------------------------
39
40 overview = """
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
43 choices.
44
45 This demo illustrates how to set up the Choice control and how to extract the
46 selected choice once it is selected.
47
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
50 <code>list</code>.
51 """
52
53
54
55
56 if __name__ == '__main__':
57 import sys,os
58 import run
59 run.main(['', os.path.basename(sys.argv[0])])
60