3 from SearchDialogBase
import SearchDialogBase
8 engine
= SearchEngine
.get(root
)
9 if not hasattr(engine
, "_searchdialog"):
10 engine
._searchdialog
= SearchDialog(root
, engine
)
11 return engine
._searchdialog
14 return _setup(text
).open(text
)
17 return _setup(text
).find_again(text
)
19 def find_selection(text
):
20 return _setup(text
).find_selection(text
)
22 class SearchDialog(SearchDialogBase
):
24 def create_widgets(self
):
25 f
= SearchDialogBase
.create_widgets(self
)
26 self
.make_button("Find", self
.default_command
, 1)
28 def default_command(self
, event
=None):
29 if not self
.engine
.getprog():
31 if self
.find_again(self
.text
):
34 def find_again(self
, text
):
35 if not self
.engine
.getpat():
38 if not self
.engine
.getprog():
40 res
= self
.engine
.search_text(text
)
44 first
= "%d.%d" % (line
, i
)
45 last
= "%d.%d" % (line
, j
)
47 selfirst
= text
.index("sel.first")
48 sellast
= text
.index("sel.last")
49 if selfirst
== first
and sellast
== last
:
54 text
.tag_remove("sel", "1.0", "end")
55 text
.tag_add("sel", first
, last
)
56 text
.mark_set("insert", self
.engine
.isback() and first
or last
)
63 def find_selection(self
, text
):
64 pat
= text
.get("sel.first", "sel.last")
66 self
.engine
.setcookedpat(pat
)
67 return self
.find_again(text
)