diff -r fa65c32d7134 Lib/idlelib/GrepDialog.py --- a/Lib/idlelib/GrepDialog.py Thu Sep 24 14:45:00 2015 +0200 +++ b/Lib/idlelib/GrepDialog.py Fri Sep 25 16:47:50 2015 -0700 @@ -6,6 +6,7 @@ from tkinter import Tk, Text, Button, SEL, END # for htest from idlelib import SearchEngine from idlelib.SearchDialogBase import SearchDialogBase +from idlelib import ui # Importing OutputWindow fails due to import loop # EditorWindow -> GrepDialop -> OutputWindow -> EditorWindow @@ -49,11 +50,12 @@ def create_other_buttons(self): f = self.make_frame()[0] - btn = Checkbutton(f, anchor="w", - variable=self.recvar, - text="Recurse down subdirectories") + btn = ui.Checkbutton(f, variable=self.recvar, + text="Recurse down subdirectories") btn.pack(side="top", fill="both") - btn.select() + self.recvar.set(True) + if not ui.using_ttk: + btn.select() def create_command_buttons(self): SearchDialogBase.create_command_buttons(self) diff -r fa65c32d7134 Lib/idlelib/SearchDialogBase.py --- a/Lib/idlelib/SearchDialogBase.py Thu Sep 24 14:45:00 2015 +0200 +++ b/Lib/idlelib/SearchDialogBase.py Fri Sep 25 16:47:50 2015 -0700 @@ -2,6 +2,8 @@ from tkinter import (Toplevel, Frame, Entry, Label, Button, Checkbutton, Radiobutton) +from idlelib import ui + class SearchDialogBase: '''Create most of a 3 or 4 row, 3 column search dialog. @@ -43,6 +45,7 @@ self.root = root self.engine = engine self.top = None + self.inner = None def open(self, text, searchphrase=None): "Make dialog visible on top of others and ready to use." @@ -79,10 +82,12 @@ top.wm_title(self.title) top.wm_iconname(self.icon) self.top = top + self.inner = ui.padframe(ui.Frame(top), 10) + self.inner.grid(column=0, row=0, sticky='nwes') self.row = 0 - self.top.grid_columnconfigure(0, pad=2, weight=0) - self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100) + self.inner.grid_columnconfigure(0, pad=2, weight=0) + self.inner.grid_columnconfigure(1, pad=2, minsize=100, weight=100) self.create_entries() # row 0 (and maybe 1), cols 0, 1 self.create_option_buttons() # next row, cols 0, 1 @@ -95,9 +100,9 @@ entry - gridded labeled Entry for text entry. label - Label widget, returned for testing. ''' - label = Label(self.top, text=label_text) + label = ui.Label(self.inner, text=label_text) label.grid(row=self.row, column=0, sticky="nw") - entry = Entry(self.top, textvariable=var, exportselection=0) + entry = ui.Entry(self.inner, textvariable=var, exportselection=0) entry.grid(row=self.row, column=1, sticky="nwe") self.row = self.row + 1 return entry, label @@ -113,11 +118,11 @@ label - Label widget, returned for testing. ''' if labeltext: - label = Label(self.top, text=labeltext) - label.grid(row=self.row, column=0, sticky="nw") + label = ui.Label(self.inner, text=labeltext) + label.grid(row=self.row, column=0, sticky="w") else: label = '' - frame = Frame(self.top) + frame = ui.Frame(self.inner) frame.grid(row=self.row, column=1, columnspan=1, sticky="nwe") self.row = self.row + 1 return frame, label @@ -129,7 +134,7 @@ A gridded frame from make_frame is filled with a Checkbutton for each pair, bound to the var, with the corresponding label. ''' - frame = self.make_frame("Options")[0] + frame = self.make_frame("Options:")[0] engine = self.engine options = [(engine.revar, "Regular expression"), (engine.casevar, "Match case"), @@ -137,9 +142,9 @@ if self.needwrapbutton: options.append((engine.wrapvar, "Wrap around")) for var, label in options: - btn = Checkbutton(frame, anchor="w", variable=var, text=label) + btn = ui.Checkbutton(frame, variable=var, text=label) btn.pack(side="left", fill="both") - if var.get(): + if not ui.using_ttk and var.get(): btn.select() return frame, options @@ -149,33 +154,38 @@ Others is a list of value, label pairs. A gridded frame from make_frame is filled with radio buttons. ''' - frame = self.make_frame("Direction")[0] + frame = self.make_frame("Direction:")[0] var = self.engine.backvar others = [(1, 'Up'), (0, 'Down')] for val, label in others: - btn = Radiobutton(frame, anchor="w", - variable=var, value=val, text=label) + btn = ui.Radiobutton(frame, variable=var, value=val, text=label) btn.pack(side="left", fill="both") - if var.get() == val: + if not ui.using_ttk and var.get() == val: btn.select() return frame, others def make_button(self, label, command, isdef=0): "Return command button gridded in command frame." - b = Button(self.buttonframe, + b = ui.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") + if ui.windowing_system == 'win32': + b.grid(pady=[0,2], row=rows, column=0, sticky='ew') + else: + b.grid(column=cols, row=0, padx=2) self.buttonframe.grid(rowspan=rows+1) return b def create_command_buttons(self): "Place buttons in vertical command frame gridded on right." - f = self.buttonframe = Frame(self.top) - f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2) + f = self.buttonframe = ui.Frame(self.inner) + if ui.windowing_system == 'win32': + f.grid(row=0, column=2, padx=[5,0], pady=0) + else: + f.grid(row=99, column=0, columnspan=2, sticky='e', pady=[10,0]) - b = self.make_button("close", self.close) + b = self.make_button("Close", self.close) b.lower() if __name__ == '__main__': diff -r fa65c32d7134 Lib/idlelib/idle_test/test_searchdialogbase.py --- a/Lib/idlelib/idle_test/test_searchdialogbase.py Thu Sep 24 14:45:00 2015 +0200 +++ b/Lib/idlelib/idle_test/test_searchdialogbase.py Fri Sep 25 16:47:50 2015 -0700 @@ -155,7 +155,7 @@ # Look for close button command in buttonframe closebuttoncommand = '' for child in self.dialog.buttonframe.winfo_children(): - if child['text'] == 'close': + if child['text'] == 'Close': closebuttoncommand = child['command'] self.assertIn('close', closebuttoncommand)