]>
Commit | Line | Data |
---|---|---|
0122b7e3 RD |
1 | |
2 | from wxPython.wx import * | |
3 | ||
4 | #--------------------------------------------------------------------------- | |
5 | ||
6 | class TestPanel(wxPanel): | |
7 | def __init__(self, parent, log): | |
8 | wxPanel.__init__(self, parent, -1) | |
9 | self.log = log | |
10 | ||
11 | b = wxButton(self, -1, "Show Find Dialog", (25, 50)) | |
12 | EVT_BUTTON(self, b.GetId(), self.OnShowFind) | |
13 | ||
14 | b = wxButton(self, -1, "Show Find && Replace Dialog", (25, 90)) | |
15 | EVT_BUTTON(self, b.GetId(), self.OnShowFindReplace) | |
16 | ||
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) | |
22 | ||
23 | ||
24 | def OnShowFind(self, evt): | |
25 | data = wxFindReplaceData() | |
26 | dlg = wxFindReplaceDialog(self, data, "Find") | |
27 | dlg.data = data # save a reference to it... | |
1e4a197e | 28 | dlg.Show(True) |
0122b7e3 RD |
29 | |
30 | ||
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... | |
1e4a197e | 35 | dlg.Show(True) |
0122b7e3 RD |
36 | |
37 | ||
38 | def OnFind(self, evt): | |
39 | map = { | |
40 | wxEVT_COMMAND_FIND : "FIND", | |
41 | wxEVT_COMMAND_FIND_NEXT : "FIND_NEXT", | |
1e4a197e | 42 | wxEVT_COMMAND_FIND_REPLACE : "REPLACE", |
0122b7e3 RD |
43 | wxEVT_COMMAND_FIND_REPLACE_ALL : "REPLACE_ALL", |
44 | } | |
45 | et = evt.GetEventType() | |
46 | ||
47 | try: | |
48 | evtType = map[et] | |
49 | except KeyError: | |
50 | evtType = "**Unknown Event Type**" | |
51 | ||
52 | if et == wxEVT_COMMAND_FIND_REPLACE or et == wxEVT_COMMAND_FIND_REPLACE_ALL: | |
53 | replaceTxt = "Replace text: " + evt.GetReplaceString() | |
54 | else: | |
55 | replaceTxt = "" | |
56 | ||
57 | self.log.write("%s -- Find text: %s %s Flags: %d \n" % | |
58 | (evtType, evt.GetFindString(), replaceTxt, evt.GetFlags())) | |
59 | ||
60 | ||
61 | def OnFindClose(self, evt): | |
62 | self.log.write("wxFindReplaceDialog closing...\n") | |
63 | evt.GetDialog().Destroy() | |
64 | ||
65 | #--------------------------------------------------------------------------- | |
66 | ||
67 | def runTest(frame, nb, log): | |
68 | win = TestPanel(nb, log) | |
69 | return win | |
70 | ||
71 | #--------------------------------------------------------------------------- | |
72 | ||
73 | ||
74 | ||
75 | ||
76 | overview = """\ | |
77 | A generic find and replace dialog. | |
78 | """ |