]>
Commit | Line | Data |
---|---|---|
8fa876ca RD |
1 | # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) |
2 | # | |
3 | # o Updated for wx namespace | |
4 | # | |
cf694132 | 5 | |
8fa876ca | 6 | import wx |
cf694132 RD |
7 | |
8 | #--------------------------------------------------------------------------- | |
9 | ||
8fa876ca | 10 | class TestChoice(wx.Panel): |
cf694132 RD |
11 | def __init__(self, parent, log): |
12 | self.log = log | |
8fa876ca | 13 | wx.Panel.__init__(self, parent, -1) |
cf694132 RD |
14 | |
15 | sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', | |
16 | 'six', 'seven', 'eight'] | |
17 | ||
8fa876ca RD |
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) | |
cf694132 | 22 | |
d56cebe7 | 23 | |
cf694132 RD |
24 | def EvtChoice(self, event): |
25 | self.log.WriteText('EvtChoice: %s\n' % event.GetString()) | |
d56cebe7 | 26 | self.ch.Append("A new item") |
8fa876ca RD |
27 | |
28 | if event.GetString() == 'one': | |
29 | self.log.WriteText('Well done!\n') | |
d56cebe7 | 30 | |
cf694132 RD |
31 | |
32 | #--------------------------------------------------------------------------- | |
33 | ||
34 | def runTest(frame, nb, log): | |
35 | win = TestChoice(nb, log) | |
36 | return win | |
37 | ||
38 | #--------------------------------------------------------------------------- | |
39 | ||
8fa876ca RD |
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. | |
cf694132 | 44 | |
8fa876ca RD |
45 | This demo illustrates how to set up the Choice control and how to extract the |
46 | selected choice once it is selected. | |
cf694132 | 47 | |
8fa876ca RD |
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>. | |
cf694132 | 51 | """ |
1fded56b RD |
52 | |
53 | ||
54 | ||
55 | ||
1fded56b RD |
56 | if __name__ == '__main__': |
57 | import sys,os | |
58 | import run | |
59 | run.main(['', os.path.basename(sys.argv[0])]) | |
60 |