def __init__(self
, root
, engine
):
def open(self
, text
, searchphrase
=None):
self
.ent
.insert("end",searchphrase
)
self
.ent
.selection_range(0, "end")
def close(self
, event
=None):
def create_widgets(self
):
top
= Toplevel(self
.root
)
top
.bind("<Return>", self
.default_command
)
top
.bind("<Escape>", self
.close
)
top
.protocol("WM_DELETE_WINDOW", self
.close
)
top
.wm_iconname(self
.icon
)
self
.top
.grid_columnconfigure(0, pad
=2, weight
=0)
self
.top
.grid_columnconfigure(1, pad
=2, minsize
=100, weight
=100)
self
.create_option_buttons()
self
.create_other_buttons()
return self
.create_command_buttons()
def make_entry(self
, label
, var
):
l
= Label(self
.top
, text
=label
)
l
.grid(row
=self
.row
, column
=0, sticky
="nw")
e
= Entry(self
.top
, textvariable
=var
, exportselection
=0)
e
.grid(row
=self
.row
, column
=1, sticky
="nwe")
def make_frame(self
,labeltext
=None):
l
= Label(self
.top
, text
=labeltext
)
l
.grid(row
=self
.row
, column
=0, sticky
="nw")
f
.grid(row
=self
.row
, column
=1, columnspan
=1, sticky
="nwe")
def make_button(self
, label
, command
, isdef
=0):
b
= Button(self
.buttonframe
,
text
=label
, command
=command
,
default
=isdef
and "active" or "normal")
cols
,rows
=self
.buttonframe
.grid_size()
b
.grid(pady
=1,row
=rows
,column
=0,sticky
="ew")
self
.buttonframe
.grid(rowspan
=rows
+1)
def create_entries(self
):
self
.ent
= self
.make_entry("Find:", self
.engine
.patvar
)
def create_option_buttons(self
):
f
= self
.make_frame("Options")
btn
= Checkbutton(f
, anchor
="w",
variable
=self
.engine
.revar
,
text
="Regular expression")
btn
.pack(side
="left", fill
="both")
btn
= Checkbutton(f
, anchor
="w",
variable
=self
.engine
.casevar
,
btn
.pack(side
="left", fill
="both")
btn
= Checkbutton(f
, anchor
="w",
variable
=self
.engine
.wordvar
,
btn
.pack(side
="left", fill
="both")
btn
= Checkbutton(f
, anchor
="w",
variable
=self
.engine
.wrapvar
,
btn
.pack(side
="left", fill
="both")
def create_other_buttons(self
):
f
= self
.make_frame("Direction")
#lbl = Label(f, text="Direction: ")
btn
= Radiobutton(f
, anchor
="w",
variable
=self
.engine
.backvar
, value
=1,
btn
.pack(side
="left", fill
="both")
btn
= Radiobutton(f
, anchor
="w",
variable
=self
.engine
.backvar
, value
=0,
btn
.pack(side
="left", fill
="both")
if not self
.engine
.isback():
def create_command_buttons(self
):
# place button frame on the right
f
= self
.buttonframe
= Frame(self
.top
)
f
.grid(row
=0,column
=2,padx
=2,pady
=2,ipadx
=2,ipady
=2)
b
= self
.make_button("close", self
.close
)