4 #----------------------------------------------------------------------
6 class TestPanel(wx
.Panel
):
7 def __init__(self
, parent
, log
):
9 wx
.Panel
.__init
__(self
, parent
, -1, style
=0)
12 sb
= wx
.StaticBox(self
, -1, "Options")
13 searchBtnOpt
= wx
.CheckBox(self
, -1, "Search button")
14 searchBtnOpt
.SetValue(True)
15 cancelBtnOpt
= wx
.CheckBox(self
, -1, "Cancel button")
16 menuBtnOpt
= wx
.CheckBox(self
, -1, "Search menu")
18 self
.search
= wx
.SearchCtrl(self
, size
=(200,-1), style
=wx
.TE_PROCESS_ENTER
)
21 box
= wx
.StaticBoxSizer(sb
, wx
.VERTICAL
)
22 box
.Add(searchBtnOpt
, 0, wx
.ALL
, 5)
23 box
.Add(cancelBtnOpt
, 0, wx
.ALL
, 5)
24 box
.Add(menuBtnOpt
, 0, wx
.ALL
, 5)
26 sizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
27 sizer
.Add(box
, 0, wx
.ALL
, 15)
29 sizer
.Add(self
.search
, 0, wx
.ALL
, 15)
31 ## self.tc = wx.TextCtrl(self) # just for testing that heights match...
32 ## sizer.Add(self.tc, 0, wx.TOP, 15)
38 self
.Bind(wx
.EVT_CHECKBOX
, self
.OnToggleSearchButton
, searchBtnOpt
)
39 self
.Bind(wx
.EVT_CHECKBOX
, self
.OnToggleCancelButton
, cancelBtnOpt
)
40 self
.Bind(wx
.EVT_CHECKBOX
, self
.OnToggleSearchMenu
, menuBtnOpt
)
42 self
.Bind(wx
.EVT_SEARCHCTRL_SEARCH_BTN
, self
.OnSearch
, self
.search
)
43 self
.Bind(wx
.EVT_SEARCHCTRL_CANCEL_BTN
, self
.OnCancel
, self
.search
)
44 self
.Bind(wx
.EVT_TEXT_ENTER
, self
.OnDoSearch
, self
.search
)
45 ##self.Bind(wx.EVT_TEXT, self.OnDoSearch, self.search)
48 def OnToggleSearchButton(self
, evt
):
49 self
.search
.ShowSearchButton( evt
.GetInt() )
51 def OnToggleCancelButton(self
, evt
):
52 self
.search
.ShowCancelButton( evt
.GetInt() )
54 def OnToggleSearchMenu(self
, evt
):
56 self
.search
.SetMenu( self
.MakeMenu() )
58 self
.search
.SetMenu(None)
61 def OnSearch(self
, evt
):
62 self
.log
.write("OnSearch")
64 def OnCancel(self
, evt
):
65 self
.log
.write("OnCancel")
67 def OnDoSearch(self
, evt
):
68 self
.log
.write("OnDoSearch: " + self
.search
.GetValue())
73 item
= menu
.Append(-1, "Recent Searches")
75 for txt
in [ "You can maintain",
77 "search strings here",
78 "and bind EVT_MENU to",
79 "catch their selections" ]:
84 #----------------------------------------------------------------------
86 def runTest(frame
, nb
, log
):
87 win
= TestPanel(nb
, log
)
90 #----------------------------------------------------------------------
94 overview
= """<html><body>
95 <h2><center>wx.SearchCtrl</center></h2>
102 if __name__
== '__main__':
105 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])