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 pat
= text
.get("sel.first", "sel.last")
15 return _setup(text
).open(text
,pat
)
18 return _setup(text
).find_again(text
)
20 def find_selection(text
):
21 return _setup(text
).find_selection(text
)
23 class SearchDialog(SearchDialogBase
):
25 def create_widgets(self
):
26 f
= SearchDialogBase
.create_widgets(self
)
27 self
.make_button("Find", self
.default_command
, 1)
29 def default_command(self
, event
=None):
30 if not self
.engine
.getprog():
32 if self
.find_again(self
.text
):
35 def find_again(self
, text
):
36 if not self
.engine
.getpat():
39 if not self
.engine
.getprog():
41 res
= self
.engine
.search_text(text
)
45 first
= "%d.%d" % (line
, i
)
46 last
= "%d.%d" % (line
, j
)
48 selfirst
= text
.index("sel.first")
49 sellast
= text
.index("sel.last")
50 if selfirst
== first
and sellast
== last
:
55 text
.tag_remove("sel", "1.0", "end")
56 text
.tag_add("sel", first
, last
)
57 text
.mark_set("insert", self
.engine
.isback() and first
or last
)
64 def find_selection(self
, text
):
65 pat
= text
.get("sel.first", "sel.last")
67 self
.engine
.setcookedpat(pat
)
68 return self
.find_again(text
)