]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ComboTreeBox.py
2 from wx
.lib
.combotreebox
import ComboTreeBox
5 #---------------------------------------------------------------------------
8 class TestComboTreeBox(wx
.Panel
):
9 def __init__(self
, parent
, log
):
10 super(TestComboTreeBox
, self
).__init
__(parent
)
12 panelSizer
= wx
.FlexGridSizer(2, 2)
13 panelSizer
.AddGrowableCol(1)
14 for style
, labelText
in [(0, 'Default style:'),
15 (wx
.CB_READONLY
, 'Read-only style:')]:
16 label
= wx
.StaticText(self
, label
=labelText
)
17 panelSizer
.Add(label
, flag
=wx
.ALL|wx
.ALIGN_CENTER_VERTICAL
,
19 comboBox
= self
._createComboTreeBox
(style
)
20 panelSizer
.Add(comboBox
, flag
=wx
.EXPAND|wx
.ALL
, border
=5)
21 self
.SetSizerAndFit(panelSizer
)
23 def _createComboTreeBox(self
, style
):
24 comboBox
= ComboTreeBox(self
, style
=style
)
25 self
._bindEventHandlers
(comboBox
)
27 child
= comboBox
.Append('Item %d'%i)
29 grandChild
= comboBox
.Append('Item %d.%d'%(i
,j
), child
)
31 comboBox
.Append('Item %d.%d.%d'%(i
,j
, k
), grandChild
)
34 def _bindEventHandlers(self
, comboBox
):
35 for eventType
, handler
in [(wx
.EVT_COMBOBOX
, self
.OnItemSelected
),
36 (wx
.EVT_TEXT
, self
.OnItemEntered
)]:
37 comboBox
.Bind(eventType
, handler
)
39 def OnItemSelected(self
, event
):
40 self
.log
.WriteText('You selected: %s\n'%event
.GetString())
43 def OnItemEntered(self
, event
):
44 self
.log
.WriteText('You entered: %s\n'%event
.GetString())
48 #---------------------------------------------------------------------------
51 def runTest(frame
, nb
, log
):
52 win
= TestComboTreeBox(nb
, log
)
56 #---------------------------------------------------------------------------
59 overview
= wx
.lib
.combotreebox
.__doc
__
62 #---------------------------------------------------------------------------
65 if __name__
== '__main__':
68 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])