X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..7eae615bad8c72486efd0ec84a2bad5c2d5af3af:/wxPython/demo/wxChoice.py diff --git a/wxPython/demo/wxChoice.py b/wxPython/demo/wxChoice.py index 55ddbb5ebf..39e2db847a 100644 --- a/wxPython/demo/wxChoice.py +++ b/wxPython/demo/wxChoice.py @@ -1,26 +1,33 @@ +# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# -from wxPython.wx import * +import wx #--------------------------------------------------------------------------- -class TestChoice(wxPanel): +class TestChoice(wx.Panel): def __init__(self, parent, log): self.log = log - wxPanel.__init__(self, parent, -1) + wx.Panel.__init__(self, parent, -1) sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'] - wxStaticText(self, -1, "This example uses the wxChoice control.", - wxPoint(15, 10)) + wx.StaticText(self, -1, "This example uses the wxChoice control.", (15, 10)) + wx.StaticText(self, -1, "Select one:", (15, 50), (75, 20)) + self.ch = wx.Choice(self, -1, (80, 50), choices = sampleList) + self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch) - wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20)) - wxChoice(self, 40, wxPoint(80, 50), wxSize(95, 20), #wxDefaultSize, - sampleList) - EVT_CHOICE(self, 40, self.EvtChoice) def EvtChoice(self, event): self.log.WriteText('EvtChoice: %s\n' % event.GetString()) + self.ch.Append("A new item") + + if event.GetString() == 'one': + self.log.WriteText('Well done!\n') + #--------------------------------------------------------------------------- @@ -30,47 +37,24 @@ def runTest(frame, nb, log): #--------------------------------------------------------------------------- +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. +This demo illustrates how to set up the Choice control and how to extract the +selected choice once it is selected. +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 +list. +""" +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) - - - - -overview = """\ -A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices. - -wxChoice() -------------------- - -Default constructor. - -wxChoice(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "choice") - -Constructor, creating and showing a choice. - -Parameters -------------------- - -parent = Parent window. Must not be NULL. - -id = Window identifier. A value of -1 indicates a default value. - -pos = Window position. - -size = Window size. If the default size (-1, -1) is specified then the choice is sized appropriately. - -n = Number of strings with which to initialise the choice control. - -choices = An array of strings with which to initialise the choice control. - -style = Window style. See wxChoice. - -validator = Window validator. - -name = Window name. -"""