+ def OnHelpFind(self, event):
+ self.nb.SetSelection(1)
+ self.finddlg = wxFindReplaceDialog(self, self.finddata, "Find",
+ wxFR_NOUPDOWN |
+ wxFR_NOMATCHCASE |
+ wxFR_NOWHOLEWORD)
+ self.finddlg.Show(True)
+
+ def OnFind(self, event):
+ self.nb.SetSelection(1)
+ end = self.txt.GetLastPosition()
+ textstring = self.txt.GetRange(0, end).lower()
+ start = self.txt.GetSelection()[1]
+ findstring = self.finddata.GetFindString().lower()
+ loc = textstring.find(findstring, start)
+ if loc == -1 and start != 0:
+ # string not found, start at beginning
+ start = 0
+ loc = textstring.find(findstring, start)
+ if loc == -1:
+ dlg = wxMessageDialog(self, 'Find String Not Found',
+ 'Find String Not Found in Demo File',
+ wxOK | wxICON_INFORMATION)
+ dlg.ShowModal()
+ dlg.Destroy()
+ if self.finddlg:
+ if loc == -1:
+ self.finddlg.SetFocus()
+ return
+ else:
+ self.finddlg.Destroy()
+ self.txt.SetSelection(loc, loc + len(findstring))
+ self.txt.ShowPosition(loc)
+
+
+
+ def OnFindNext(self, event):
+ if self.finddata.GetFindString():
+ self.OnFind(event)
+ else:
+ self.OnHelpFind(event)
+
+ def OnFindClose(self, event):
+ event.GetDialog().Destroy()
+