3 class SearchDialogBase
:
5 title
= "Search Dialog"
9 def __init__(self
, root
, engine
):
14 def open(self
, text
, searchphrase
=None):
22 self
.ent
.delete(0,"end")
23 self
.ent
.insert("end",searchphrase
)
25 self
.ent
.selection_range(0, "end")
29 def close(self
, event
=None):
31 self
.top
.grab_release()
34 def create_widgets(self
):
35 top
= Toplevel(self
.root
)
36 top
.bind("<Return>", self
.default_command
)
37 top
.bind("<Escape>", self
.close
)
38 top
.protocol("WM_DELETE_WINDOW", self
.close
)
39 top
.wm_title(self
.title
)
40 top
.wm_iconname(self
.icon
)
44 self
.top
.grid_columnconfigure(0, pad
=2, weight
=0)
45 self
.top
.grid_columnconfigure(1, pad
=2, minsize
=100, weight
=100)
48 self
.create_option_buttons()
49 self
.create_other_buttons()
50 return self
.create_command_buttons()
52 def make_entry(self
, label
, var
):
53 l
= Label(self
.top
, text
=label
)
54 l
.grid(row
=self
.row
, column
=0, sticky
="nw")
55 e
= Entry(self
.top
, textvariable
=var
, exportselection
=0)
56 e
.grid(row
=self
.row
, column
=1, sticky
="nwe")
57 self
.row
= self
.row
+ 1
60 def make_frame(self
,labeltext
=None):
62 l
= Label(self
.top
, text
=labeltext
)
63 l
.grid(row
=self
.row
, column
=0, sticky
="nw")
65 f
.grid(row
=self
.row
, column
=1, columnspan
=1, sticky
="nwe")
66 self
.row
= self
.row
+ 1
69 def make_button(self
, label
, command
, isdef
=0):
70 b
= Button(self
.buttonframe
,
71 text
=label
, command
=command
,
72 default
=isdef
and "active" or "normal")
73 cols
,rows
=self
.buttonframe
.grid_size()
74 b
.grid(pady
=1,row
=rows
,column
=0,sticky
="ew")
75 self
.buttonframe
.grid(rowspan
=rows
+1)
78 def create_entries(self
):
79 self
.ent
= self
.make_entry("Find:", self
.engine
.patvar
)
81 def create_option_buttons(self
):
82 f
= self
.make_frame("Options")
84 btn
= Checkbutton(f
, anchor
="w",
85 variable
=self
.engine
.revar
,
86 text
="Regular expression")
87 btn
.pack(side
="left", fill
="both")
88 if self
.engine
.isre():
91 btn
= Checkbutton(f
, anchor
="w",
92 variable
=self
.engine
.casevar
,
94 btn
.pack(side
="left", fill
="both")
95 if self
.engine
.iscase():
98 btn
= Checkbutton(f
, anchor
="w",
99 variable
=self
.engine
.wordvar
,
101 btn
.pack(side
="left", fill
="both")
102 if self
.engine
.isword():
105 if self
.needwrapbutton
:
106 btn
= Checkbutton(f
, anchor
="w",
107 variable
=self
.engine
.wrapvar
,
109 btn
.pack(side
="left", fill
="both")
110 if self
.engine
.iswrap():
113 def create_other_buttons(self
):
114 f
= self
.make_frame("Direction")
116 #lbl = Label(f, text="Direction: ")
117 #lbl.pack(side="left")
119 btn
= Radiobutton(f
, anchor
="w",
120 variable
=self
.engine
.backvar
, value
=1,
122 btn
.pack(side
="left", fill
="both")
123 if self
.engine
.isback():
126 btn
= Radiobutton(f
, anchor
="w",
127 variable
=self
.engine
.backvar
, value
=0,
129 btn
.pack(side
="left", fill
="both")
130 if not self
.engine
.isback():
133 def create_command_buttons(self
):
135 # place button frame on the right
136 f
= self
.buttonframe
= Frame(self
.top
)
137 f
.grid(row
=0,column
=2,padx
=2,pady
=2,ipadx
=2,ipady
=2)
139 b
= self
.make_button("close", self
.close
)