Skip to content

Commit 059dc68

Browse files
committed
Improve IDLE Find, Replace and Find in Files dialogs
1 parent 9187484 commit 059dc68

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

Lib/idlelib/News3.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
What's New in IDLE 3.14.0
2+
(since 3.13.0)
3+
Released on 2025-10-xx
4+
=========================
5+
6+
7+
gh-67407: Improve the Find, Replace and Find in Files dialogs. Patch by
8+
Wulian233 and AlSweigart.
9+
10+
111
What's New in IDLE 3.13.0
212
(since 3.12.0)
313
Released on 2024-10-xx

Lib/idlelib/grep.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sys
99

1010
from tkinter import StringVar, BooleanVar
11-
from tkinter.ttk import Checkbutton # Frame imported in ...Base
11+
from tkinter.ttk import Checkbutton, Frame
1212

1313
from idlelib.searchbase import SearchDialogBase
1414
from idlelib import searchengine
@@ -64,7 +64,7 @@ def findfiles(folder, pattern, recursive):
6464
class GrepDialog(SearchDialogBase):
6565
"Dialog for searching multiple files."
6666

67-
title = "Find in Files Dialog"
67+
title = "Find in Files"
6868
icon = "Grep"
6969
needwrapbutton = 0
7070

@@ -112,7 +112,7 @@ def open(self, text, searchphrase, io=None):
112112
def create_entries(self):
113113
"Create base entry widgets and add widget for search path."
114114
SearchDialogBase.create_entries(self)
115-
self.globent = self.make_entry("In files:", self.globvar)[0]
115+
self.globent = self.make_entry("In files", self.globvar)[0]
116116

117117
def create_other_buttons(self):
118118
"Add check button to recurse down subdirectories."
@@ -122,9 +122,10 @@ def create_other_buttons(self):
122122
btn.pack(side="top", fill="both")
123123

124124
def create_command_buttons(self):
125-
"Create base command buttons and add button for Search Files."
126-
SearchDialogBase.create_command_buttons(self)
127-
self.make_button("Search Files", self.default_command, isdef=True)
125+
"""Create base command buttons and add button for Search Files."""
126+
f = self.buttonframe = Frame(self.frame)
127+
f.grid(row=3, column=2, padx=4, pady=4)
128+
self.make_button("Search", self.default_command, isdef=True)
128129

129130
def default_command(self, event=None):
130131
"""Grep for search pattern in file path. The default command is bound

Lib/idlelib/replace.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def replace(text, insert_tags=None):
3232
class ReplaceDialog(SearchDialogBase):
3333
"Dialog for finding and replacing a pattern in text."
3434

35-
title = "Replace Dialog"
35+
title = "Replace"
3636
icon = "Replace"
3737

3838
def __init__(self, root, engine):
@@ -69,7 +69,7 @@ def open(self, text, searchphrase=None, *, insert_tags=None):
6969
def create_entries(self):
7070
"Create base and additional label and text entry widgets."
7171
SearchDialogBase.create_entries(self)
72-
self.replent = self.make_entry("Replace with:", self.replvar)[0]
72+
self.replent = self.make_entry("Replace with", self.replvar)[0]
7373

7474
def create_command_buttons(self):
7575
"""Create base and additional command buttons.
@@ -78,22 +78,14 @@ def create_command_buttons(self):
7878
Replace+Find, and Replace All.
7979
"""
8080
SearchDialogBase.create_command_buttons(self)
81-
self.make_button("Find", self.find_it)
82-
self.make_button("Replace", self.replace_it)
83-
self.make_button("Replace+Find", self.default_command, isdef=True)
81+
self.make_button("Find Next", self.find_it)
82+
self.make_button("Replace", self.default_command, isdef=True)
8483
self.make_button("Replace All", self.replace_all)
8584

8685
def find_it(self, event=None):
8786
"Handle the Find button."
8887
self.do_find(False)
8988

90-
def replace_it(self, event=None):
91-
"""Handle the Replace button.
92-
93-
If the find is successful, then perform replace.
94-
"""
95-
if self.do_find(self.ok):
96-
self.do_replace()
9789

9890
def default_command(self, event=None):
9991
"""Handle the Replace+Find button as the default command.

Lib/idlelib/searchbase.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SearchDialogBase:
2626
add widgets.
2727
'''
2828

29-
title = "Search Dialog" # replace in subclasses
29+
title = "Find" # replace in subclasses
3030
icon = "Search"
3131
needwrapbutton = 1 # not in Find in Files
3232

@@ -92,8 +92,6 @@ def create_widgets(self):
9292
top.grid_rowconfigure(0, weight=100)
9393

9494
self.row = 0
95-
self.frame.grid_columnconfigure(0, pad=2, weight=0)
96-
self.frame.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
9795

9896
self.create_entries() # row 0 (and maybe 1), cols 0, 1
9997
self.create_option_buttons() # next row, cols 0, 1
@@ -109,13 +107,13 @@ def make_entry(self, label_text, var):
109107
label = Label(self.frame, text=label_text)
110108
label.grid(row=self.row, column=0, sticky="nw")
111109
entry = Entry(self.frame, textvariable=var, exportselection=0)
112-
entry.grid(row=self.row, column=1, sticky="nwe")
113-
self.row = self.row + 1
110+
entry.grid(row=self.row, column=1, columnspan=2, padx=4, pady=4, sticky="nwe")
111+
self.row += 1
114112
return entry, label
115113

116114
def create_entries(self):
117115
"Create one or more entry lines with make_entry."
118-
self.ent = self.make_entry("Find:", self.engine.patvar)[0]
116+
self.ent = self.make_entry("Find", self.engine.patvar)[0]
119117

120118
def make_frame(self,labeltext=None):
121119
'''Return (frame, label).
@@ -179,10 +177,7 @@ def make_button(self, label, command, isdef=0):
179177
def create_command_buttons(self):
180178
"Place buttons in vertical command frame gridded on right."
181179
f = self.buttonframe = Frame(self.frame)
182-
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
183-
184-
b = self.make_button("Close", self.close)
185-
b.lower()
180+
f.grid(row=2, column=2, padx=4, pady=4)
186181

187182

188183
class _searchbase(SearchDialogBase): # htest #
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve IDLE Find, Replace and Find in Files dialogs. Patch by Wulian233 and
2+
AlSweigart.

0 commit comments

Comments
 (0)