2 from wxPython
.wx 
import * 
   4 #--------------------------------------------------------------------------- 
   6 class TestPanel(wxPanel
): 
   7     def __init__(self
, parent
, log
): 
   8         wxPanel
.__init
__(self
, parent
, -1) 
  11         b 
= wxButton(self
, -1, "Show Find Dialog", (25, 50)) 
  12         EVT_BUTTON(self
, b
.GetId(), self
.OnShowFind
) 
  14         b 
= wxButton(self
, -1, "Show Find && Replace Dialog", (25, 90)) 
  15         EVT_BUTTON(self
, b
.GetId(), self
.OnShowFindReplace
) 
  17         EVT_COMMAND_FIND(self
, -1, self
.OnFind
) 
  18         EVT_COMMAND_FIND_NEXT(self
, -1, self
.OnFind
) 
  19         EVT_COMMAND_FIND_REPLACE(self
, -1, self
.OnFind
) 
  20         EVT_COMMAND_FIND_REPLACE_ALL(self
, -1, self
.OnFind
) 
  21         EVT_COMMAND_FIND_CLOSE(self
, -1, self
.OnFindClose
) 
  24     def OnShowFind(self
, evt
): 
  25         data 
= wxFindReplaceData() 
  26         dlg 
= wxFindReplaceDialog(self
, data
, "Find") 
  27         dlg
.data 
= data  
# save a reference to it... 
  31     def OnShowFindReplace(self
, evt
): 
  32         data 
= wxFindReplaceData() 
  33         dlg 
= wxFindReplaceDialog(self
, data
, "Find & Replace", wxFR_REPLACEDIALOG
) 
  34         dlg
.data 
= data  
# save a reference to it... 
  38     def OnFind(self
, evt
): 
  40             wxEVT_COMMAND_FIND 
: "FIND", 
  41             wxEVT_COMMAND_FIND_NEXT 
: "FIND_NEXT", 
  42             wxEVT_COMMAND_FIND_REPLACE 
: "REPALCE", 
  43             wxEVT_COMMAND_FIND_REPLACE_ALL 
: "REPLACE_ALL", 
  45         et 
= evt
.GetEventType() 
  50             evtType 
= "**Unknown Event Type**" 
  52         if et 
== wxEVT_COMMAND_FIND_REPLACE 
or et 
== wxEVT_COMMAND_FIND_REPLACE_ALL
: 
  53             replaceTxt 
= "Replace text: " + evt
.GetReplaceString() 
  57         self
.log
.write("%s -- Find text: %s  %s  Flags: %d  \n" % 
  58                        (evtType
, evt
.GetFindString(), replaceTxt
, evt
.GetFlags())) 
  61     def OnFindClose(self
, evt
): 
  62         self
.log
.write("wxFindReplaceDialog closing...\n") 
  63         evt
.GetDialog().Destroy() 
  65 #--------------------------------------------------------------------------- 
  67 def runTest(frame
, nb
, log
): 
  68     win 
= TestPanel(nb
, log
) 
  71 #--------------------------------------------------------------------------- 
  77 A generic find and replace dialog.