Files
wxWidgets/wxPython/demo/wxFindReplaceDialog.py
Robin Dunn 64dfb023eb Switched to using True/False in the wxPython lib and demo instead of
true/false or TRUE/FALSE to prepare for the new boolean type and
constants being added to Python.  Added code to wx.py to test for the
existence of the new constants and to create suitable values if not
present.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19335 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-02-26 18:38:37 +00:00

79 lines
2.3 KiB
Python

from wxPython.wx import *
#---------------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.log = log
b = wxButton(self, -1, "Show Find Dialog", (25, 50))
EVT_BUTTON(self, b.GetId(), self.OnShowFind)
b = wxButton(self, -1, "Show Find && Replace Dialog", (25, 90))
EVT_BUTTON(self, b.GetId(), self.OnShowFindReplace)
EVT_COMMAND_FIND(self, -1, self.OnFind)
EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind)
EVT_COMMAND_FIND_REPLACE(self, -1, self.OnFind)
EVT_COMMAND_FIND_REPLACE_ALL(self, -1, self.OnFind)
EVT_COMMAND_FIND_CLOSE(self, -1, self.OnFindClose)
def OnShowFind(self, evt):
data = wxFindReplaceData()
dlg = wxFindReplaceDialog(self, data, "Find")
dlg.data = data # save a reference to it...
dlg.Show(True)
def OnShowFindReplace(self, evt):
data = wxFindReplaceData()
dlg = wxFindReplaceDialog(self, data, "Find & Replace", wxFR_REPLACEDIALOG)
dlg.data = data # save a reference to it...
dlg.Show(True)
def OnFind(self, evt):
map = {
wxEVT_COMMAND_FIND : "FIND",
wxEVT_COMMAND_FIND_NEXT : "FIND_NEXT",
wxEVT_COMMAND_FIND_REPLACE : "REPLACE",
wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL",
}
et = evt.GetEventType()
try:
evtType = map[et]
except KeyError:
evtType = "**Unknown Event Type**"
if et == wxEVT_COMMAND_FIND_REPLACE or et == wxEVT_COMMAND_FIND_REPLACE_ALL:
replaceTxt = "Replace text: " + evt.GetReplaceString()
else:
replaceTxt = ""
self.log.write("%s -- Find text: %s %s Flags: %d \n" %
(evtType, evt.GetFindString(), replaceTxt, evt.GetFlags()))
def OnFindClose(self, evt):
self.log.write("wxFindReplaceDialog closing...\n")
evt.GetDialog().Destroy()
#---------------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
A generic find and replace dialog.
"""