1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestChoice(wx.Panel):
|
1999-04-30 03:29:54 +00:00
|
|
|
def __init__(self, parent, log):
|
|
|
|
self.log = log
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
|
|
|
'six', 'seven', 'eight']
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.StaticText(self, -1, "This example uses the wxChoice control.", (15, 10))
|
2004-06-16 03:29:33 +00:00
|
|
|
wx.StaticText(self, -1, "Select one:", (15, 50), (75, -1))
|
|
|
|
self.ch = wx.Choice(self, -1, (100, 50), choices = sampleList)
|
2003-12-09 01:23:28 +00:00
|
|
|
self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2001-06-15 21:43:26 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
def EvtChoice(self, event):
|
|
|
|
self.log.WriteText('EvtChoice: %s\n' % event.GetString())
|
2001-06-15 21:43:26 +00:00
|
|
|
self.ch.Append("A new item")
|
2003-12-09 01:23:28 +00:00
|
|
|
|
|
|
|
if event.GetString() == 'one':
|
|
|
|
self.log.WriteText('Well done!\n')
|
2001-06-15 21:43:26 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestChoice(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
overview = """
|
|
|
|
A Choice control is used to select one of a list of strings. Unlike a listbox,
|
|
|
|
only the current selection is visible until the user pulls down the menu of
|
|
|
|
choices.
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
This demo illustrates how to set up the Choice control and how to extract the
|
|
|
|
selected choice once it is selected.
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
Note that the syntax of the constructor is different than the C++ implementation.
|
|
|
|
The number of choices and the choice array are consilidated into one python
|
|
|
|
<code>list</code>.
|
1999-04-30 03:29:54 +00:00
|
|
|
"""
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2003-07-02 23:13:10 +00:00
|
|
|
|