4 class SearchDialogBase
:
6 title
= "Search Dialog"
10 def __init__(self
, root
, engine
):
23 self
.ent
.selection_range(0, "end")
27 def close(self
, event
=None):
29 self
.top
.grab_release()
32 def create_widgets(self
):
33 top
= Toplevel(self
.root
)
34 top
.bind("<Return>", self
.default_command
)
35 top
.bind("<Escape>", self
.close
)
36 top
.protocol("WM_DELETE_WINDOW", self
.close
)
37 top
.wm_title(self
.title
)
38 top
.wm_iconname(self
.icon
)
42 self
.top
.grid_columnconfigure(0, weight
=0)
43 self
.top
.grid_columnconfigure(1, weight
=100)
46 self
.create_option_buttons()
47 self
.create_other_buttons()
48 return self
.create_command_buttons()
50 def make_entry(self
, label
, var
):
51 l
= Label(self
.top
, text
=label
)
52 l
.grid(row
=self
.row
, col
=0, sticky
="w")
53 e
= Entry(self
.top
, textvariable
=var
, exportselection
=0)
54 e
.grid(row
=self
.row
, col
=1, sticky
="we")
55 self
.row
= self
.row
+ 1
60 f
.grid(row
=self
.row
, col
=0, columnspan
=2, sticky
="we")
61 self
.row
= self
.row
+ 1
64 def make_button(self
, label
, command
, isdef
=0, side
="left"):
65 b
= Button(self
.buttonframe
,
66 text
=label
, command
=command
,
67 default
=isdef
and "active" or "normal")
71 def create_entries(self
):
72 self
.ent
= self
.make_entry("Find:", self
.engine
.patvar
)
74 def create_option_buttons(self
):
77 btn
= Checkbutton(f
, anchor
="w",
78 variable
=self
.engine
.revar
,
79 text
="Regular expression")
80 btn
.pack(side
="left", fill
="both")
81 if self
.engine
.isre():
84 btn
= Checkbutton(f
, anchor
="w",
85 variable
=self
.engine
.casevar
,
87 btn
.pack(side
="left", fill
="both")
88 if self
.engine
.iscase():
91 btn
= Checkbutton(f
, anchor
="w",
92 variable
=self
.engine
.wordvar
,
94 btn
.pack(side
="left", fill
="both")
95 if self
.engine
.isword():
98 if self
.needwrapbutton
:
99 btn
= Checkbutton(f
, anchor
="w",
100 variable
=self
.engine
.wrapvar
,
102 btn
.pack(side
="left", fill
="both")
103 if self
.engine
.iswrap():
106 def create_other_buttons(self
):
107 f
= self
.make_frame()
109 lbl
= Label(f
, text
="Direction: ")
110 lbl
.pack(side
="left")
112 btn
= Radiobutton(f
, anchor
="w",
113 variable
=self
.engine
.backvar
, value
=1,
115 btn
.pack(side
="left", fill
="both")
116 if self
.engine
.isback():
119 btn
= Radiobutton(f
, anchor
="w",
120 variable
=self
.engine
.backvar
, value
=0,
122 btn
.pack(side
="left", fill
="both")
123 if not self
.engine
.isback():
126 def create_command_buttons(self
):
127 f
= self
.buttonframe
= self
.make_frame()
128 b
= self
.make_button("close", self
.close
, side
="right")