storysearchframes.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import wx
  2. from searchpanels import FindPanel, ReplacePanel
  3. class StoryFindFrame(wx.Frame):
  4. """
  5. This allows the user to search a StoryPanel for a string of text.
  6. This is just a front-end to method calls on StoryPanel.
  7. """
  8. def __init__(self, storyPanel, app, parent = None):
  9. self.storyPanel = storyPanel
  10. self.app = app
  11. wx.Frame.__init__(self, parent, wx.ID_ANY, title = 'Find in Story', \
  12. style = wx.MINIMIZE_BOX | wx.CLOSE_BOX | wx.CAPTION | wx.SYSTEM_MENU)
  13. sizer = wx.BoxSizer(wx.VERTICAL)
  14. self.SetSizer(sizer)
  15. findPanel = FindPanel(parent = self, onFind = self.onFind, onClose = self.onClose)
  16. findPanel.focus()
  17. sizer.Add(findPanel)
  18. sizer.Fit(self)
  19. self.SetIcon(self.app.icon)
  20. self.Show()
  21. def onFind(self, regexp, flags):
  22. self.storyPanel.findWidgetRegexp(regexp, flags)
  23. def onClose(self):
  24. self.Close()
  25. class StoryReplaceFrame(wx.Frame):
  26. """
  27. This allows the user to replace text across an entire StoryPanel.
  28. This is just a front-end to method calls on StoryPanel.
  29. """
  30. def __init__(self, storyPanel, app, parent = None):
  31. self.storyPanel = storyPanel
  32. self.app = app
  33. wx.Frame.__init__(self, parent, wx.ID_ANY, title = 'Replace Across Entire Story', \
  34. style = wx.MINIMIZE_BOX | wx.CLOSE_BOX | wx.CAPTION | wx.SYSTEM_MENU)
  35. sizer = wx.BoxSizer(wx.VERTICAL)
  36. self.SetSizer(sizer)
  37. replacePanel = ReplacePanel(self, allowIncremental = True, \
  38. onFind=self.onFind, onReplace=self.onReplace, \
  39. onReplaceAll = self.onReplaceAll, onClose = self.onClose)
  40. sizer.Add(replacePanel)
  41. replacePanel.focus()
  42. sizer.Fit(self)
  43. self.SetIcon(self.app.icon)
  44. self.Show()
  45. def onFind(self, regexp, flags):
  46. self.storyPanel.findWidgetRegexp(regexp, flags)
  47. def onReplace(self, findRegexp, flags, replaceRegexp):
  48. self.storyPanel.replaceRegexpInSelectedWidget(findRegexp, replaceRegexp, flags)
  49. def onReplaceAll(self, findRegexp, flags, replaceRegexp):
  50. self.storyPanel.replaceRegexpInWidgets(findRegexp, replaceRegexp, flags)
  51. def onClose(self):
  52. self.Close()