]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxComboBox.py
info about removal of wxhtml.rc
[wxWidgets.git] / wxPython / demo / wxComboBox.py
CommitLineData
68bc8549 1import string
cf694132
RD
2from wxPython.wx import *
3
4#---------------------------------------------------------------------------
5
6class TestComboBox(wxPanel):
059a841c
RD
7 def OnSetFocus(self, evt):
8 print "OnSetFocus"
9 evt.Skip()
10 def OnKillFocus(self, evt):
11 print "OnKillFocus"
12 evt.Skip()
13
cf694132
RD
14 def __init__(self, parent, log):
15 self.log = log
16 wxPanel.__init__(self, parent, -1)
17
18 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
19 'six', 'seven', 'eight']
20
21 wxStaticText(self, -1, "This example uses the wxComboBox control.",
22 wxPoint(8, 10))
23
24 wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
059a841c 25 cb = wxComboBox(self, 500, "default value", wxPoint(80, 50), wxSize(95, -1),
468c1af0 26 sampleList, wxCB_DROPDOWN|wxTE_PROCESS_ENTER)
8bf5d46e 27 EVT_COMBOBOX(self, 500, self.EvtComboBox)
f6bcfd97 28 EVT_TEXT(self, 500, self.EvtText)
468c1af0 29 EVT_TEXT_ENTER(self, 500, self.EvtTextEnter)
059a841c
RD
30 EVT_SET_FOCUS(cb, self.OnSetFocus)
31 EVT_KILL_FOCUS(cb, self.OnKillFocus)
32
3bbeffe4 33 cb.Append("foo", "This is some client data for this item")
059a841c 34
68bc8549
RD
35 cb = wxComboBox(self, 501, "default value", wxPoint(80, 80), wxSize(95, -1),
36 [], wxCB_SIMPLE)
37 for item in sampleList:
38 cb.Append(item, string.upper(item))
059a841c
RD
39 EVT_COMBOBOX(self, 501, self.EvtComboBox)
40 EVT_TEXT(self, 501, self.EvtText)
cf694132
RD
41
42
3bbeffe4
RD
43 def EvtComboBox(self, evt):
44 cb = evt.GetEventObject()
45 data = cb.GetClientData(cb.GetSelection())
46 self.log.WriteText('EvtComboBox: %s\nClientData: %s\n' % (evt.GetString(), data))
cf694132 47
3bbeffe4
RD
48 def EvtText(self, evt):
49 self.log.WriteText('EvtText: %s\n' % evt.GetString())
f6bcfd97 50
468c1af0
RD
51 def EvtTextEnter(self, evt):
52 self.log.WriteText('EvtTextEnter: does this work?')
53
cf694132
RD
54#---------------------------------------------------------------------------
55
56def runTest(frame, nb, log):
57 win = TestComboBox(nb, log)
58 return win
59
60#---------------------------------------------------------------------------
61
62
63
64
65
66
67
68
69
70
71
72
73overview = """\
74A combobox is like a combination of an edit control and a listbox. It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
75
cf694132 76"""