cpython: b6c5719e0f4e (original) (raw)
--- a/Lib/idlelib/GrepDialog.py +++ b/Lib/idlelib/GrepDialog.py @@ -45,10 +45,10 @@ class GrepDialog(SearchDialogBase): def create_entries(self): SearchDialogBase.create_entries(self)
self.globent = self.make_entry("In files:", self.globvar)[](#l1.7)
self.globent = self.make_entry("In files:", self.globvar)[0][](#l1.8)
def create_other_buttons(self):
f = self.make_frame()[](#l1.11)
f = self.make_frame()[0][](#l1.12)
btn = Checkbutton(f, anchor="w", variable=self.recvar,
--- a/Lib/idlelib/ReplaceDialog.py +++ b/Lib/idlelib/ReplaceDialog.py @@ -40,7 +40,7 @@ class ReplaceDialog(SearchDialogBase): def create_entries(self): SearchDialogBase.create_entries(self)
self.replent = self.make_entry("Replace with:", self.replvar)[](#l2.7)
self.replent = self.make_entry("Replace with:", self.replvar)[0][](#l2.8)
def create_command_buttons(self): SearchDialogBase.create_command_buttons(self)
--- a/Lib/idlelib/SearchDialogBase.py +++ b/Lib/idlelib/SearchDialogBase.py @@ -89,21 +89,29 @@ class SearchDialogBase: self.create_other_buttons() # next row, cols 0, 1 self.create_command_buttons() # col 2, all rows
- def make_entry(self, label, var):
"Return gridded labeled Entry."[](#l3.8)
l = Label(self.top, text=label)[](#l3.9)
l.grid(row=self.row, column=0, sticky="nw")[](#l3.10)
e = Entry(self.top, textvariable=var, exportselection=0)[](#l3.11)
e.grid(row=self.row, column=1, sticky="nwe")[](#l3.12)
entry - gridded labeled Entry for text entry.[](#l3.16)
label - Label widget, returned for testing.[](#l3.17)
'''[](#l3.18)
label = Label(self.top, text=label_text)[](#l3.19)
label.grid(row=self.row, column=0, sticky="nw")[](#l3.20)
entry = Entry(self.top, textvariable=var, exportselection=0)[](#l3.21)
entry.grid(row=self.row, column=1, sticky="nwe")[](#l3.22) self.row = self.row + 1[](#l3.23)
return l, e # return label for testing[](#l3.24)
return entry, label[](#l3.25)
def create_entries(self): "Create one or more entry lines with make_entry."
self.ent = self.make_entry("Find:", self.engine.patvar)[1][](#l3.29)
self.ent = self.make_entry("Find:", self.engine.patvar)[0][](#l3.30)
def make_frame(self,labeltext=None):
"Return gridded labeled Frame for option or other buttons."[](#l3.33)
'''Return (frame, label).[](#l3.34)
frame - gridded labeled Frame for option or other buttons.[](#l3.36)
label - Label widget, returned for testing.[](#l3.37)
'''[](#l3.38) if labeltext:[](#l3.39) label = Label(self.top, text=labeltext)[](#l3.40) label.grid(row=self.row, column=0, sticky="nw")[](#l3.41)
@@ -112,10 +120,15 @@ class SearchDialogBase: frame = Frame(self.top) frame.grid(row=self.row, column=1, columnspan=1, sticky="nwe") self.row = self.row + 1
return frame, label # label for test[](#l3.46)
return frame, label[](#l3.47)
def create_option_buttons(self):
"Fill frame with Checkbuttons bound to SearchEngine booleanvars."[](#l3.50)
'''Return (filled frame, options) for testing.[](#l3.51)
Options is a list of SearchEngine booleanvar, label pairs.[](#l3.53)
A gridded frame from make_frame is filled with a Checkbutton[](#l3.54)
for each pair, bound to the var, with the corresponding label.[](#l3.55)
'''[](#l3.56) frame = self.make_frame("Options")[0][](#l3.57) engine = self.engine[](#l3.58) options = [(engine.revar, "Regular expression"),[](#l3.59)
@@ -128,10 +141,14 @@ class SearchDialogBase: btn.pack(side="left", fill="both") if var.get(): btn.select()
return frame, options # for test[](#l3.64)
return frame, options[](#l3.65)
def create_other_buttons(self):
"Fill frame with buttons tied to other options."[](#l3.68)
'''Return (frame, others) for testing.[](#l3.69)
Others is a list of value, label pairs.[](#l3.71)
A gridded frame from make_frame is filled with radio buttons.[](#l3.72)
'''[](#l3.73) frame = self.make_frame("Direction")[0][](#l3.74) var = self.engine.backvar[](#l3.75) others = [(1, 'Up'), (0, 'Down')][](#l3.76)
@@ -139,10 +156,9 @@ class SearchDialogBase: btn = Radiobutton(frame, anchor="w", variable=var, value=val, text=label) btn.pack(side="left", fill="both")
#print(var.get(), val, label)[](#l3.81) if var.get() == val:[](#l3.82) btn.select()[](#l3.83)
return frame, others # for test[](#l3.84)
return frame, others[](#l3.85)
def make_button(self, label, command, isdef=0): "Return command button gridded in command frame."
--- a/Lib/idlelib/idle_test/test_searchdialogbase.py +++ b/Lib/idlelib/idle_test/test_searchdialogbase.py @@ -75,7 +75,7 @@ class SearchDialogBaseTest(unittest.Test equal = self.assertEqual self.dialog.row = 0 self.dialog.top = Toplevel(self.root)
label, entry = self.dialog.make_entry("Test:", 'hello')[](#l4.7)
entry, label = self.dialog.make_entry("Test:", 'hello')[](#l4.8) equal(label['text'], 'Test:')[](#l4.9)