X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/299647acac7960652aadb008775429c1f8ea9b8d..aec587c2f2ddb0fcd08640bc412d3176ba8c2474:/wxPython/demo/FindReplaceDialog.py diff --git a/wxPython/demo/FindReplaceDialog.py b/wxPython/demo/FindReplaceDialog.py index 54cc07ee3b..5f6f71463f 100644 --- a/wxPython/demo/FindReplaceDialog.py +++ b/wxPython/demo/FindReplaceDialog.py @@ -18,28 +18,28 @@ class TestPanel(wx.Panel): wx.Panel.__init__(self, parent, -1) self.log = log - b = wx.Button(self, -1, "Show Find Dialog", (25, 50)) - self.Bind(wx.EVT_BUTTON, self.OnShowFind, b) + self.fbtn = wx.Button(self, -1, "Show Find Dialog", (25, 50)) + self.Bind(wx.EVT_BUTTON, self.OnShowFind, self.fbtn) - b = wx.Button(self, -1, "Show Find && Replace Dialog", (25, 90)) - self.Bind(wx.EVT_BUTTON, self.OnShowFindReplace, b) + self.frbtn = wx.Button(self, -1, "Show Find && Replace Dialog", (25, 90)) + self.Bind(wx.EVT_BUTTON, self.OnShowFindReplace, self.frbtn) - - # jg - 11/28/03 - corrected a long standing issue here where - # EVT_COMMAND_FIND_* was being used for these event binders - # instead of the actual event IDs shown below. As a result, - # onFind() was never showing the appropriate type. I guess - # nobody really paid much attention to that little - # debugging window :-) - # self.Bind(wx.EVT_FIND, self.OnFind) self.Bind(wx.EVT_FIND_NEXT, self.OnFind) self.Bind(wx.EVT_FIND_REPLACE, self.OnFind) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFind) self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose) + def EnableButtons(self): + self.fbtn.Enable() + self.frbtn.Enable() + + def DisableButtons(self): + self.fbtn.Disable() + self.frbtn.Disable() def OnShowFind(self, evt): + self.DisableButtons() data = wx.FindReplaceData() dlg = wx.FindReplaceDialog(self, data, "Find") dlg.data = data # save a reference to it... @@ -47,6 +47,7 @@ class TestPanel(wx.Panel): def OnShowFindReplace(self, evt): + self.DisableButtons() data = wx.FindReplaceData() dlg = wx.FindReplaceDialog(self, data, "Find & Replace", wx.FR_REPLACEDIALOG) dlg.data = data # save a reference to it... @@ -63,8 +64,6 @@ class TestPanel(wx.Panel): et = evt.GetEventType() - #print evt.GetReplaceString() - if et in map: evtType = map[et] else: @@ -77,13 +76,15 @@ class TestPanel(wx.Panel): else: replaceTxt = "" - self.log.write("%s -- Find text: %s %s Flags: %d \n" % + self.log.write("%s -- Find text: %s Replace text: %s Flags: %d \n" % (evtType, evt.GetFindString(), replaceTxt, evt.GetFlags())) def OnFindClose(self, evt): self.log.write("FindReplaceDialog closing...\n") evt.GetDialog().Destroy() + self.EnableButtons() + #--------------------------------------------------------------------------- @@ -119,5 +120,5 @@ will be invalid after the parent dialog is destroyed. if __name__ == '__main__': import sys,os import run - run.main(['', os.path.basename(sys.argv[0])]) + run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])