Skip to content

Commit 3e78c40

Browse files
gh-152940: Add a Unicode character browser to IDLE
Add a Character Browser command to the Edit menu (Shell and editor). It opens a window for browsing Unicode blocks in a grid, viewing a character's details, and searching by name or code point. A character can be inserted at the cursor of the editor or shell, or copied to the clipboard. On the detail tabs, a representation or normalization form can be clicked to copy it or double-clicked to insert it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a50b089 commit 3e78c40

9 files changed

Lines changed: 1263 additions & 2 deletions

File tree

Doc/library/idle.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ Show Call Tip
170170
Show Surrounding Parens
171171
Highlight the surrounding parenthesis.
172172

173+
Character Browser
174+
Open a window to browse Unicode blocks and search for characters by name or code point.
175+
Double-click a character, or select it and press Insert, to insert it into the current window.
176+
Press Copy character to copy it to the clipboard.
177+
The detail tabs show the character's representations, such as escapes, UTF-8 bytes, XML and HTML references, and normalization forms.
178+
Click a highlighted value to copy it, or double-click it to insert it.
179+
173180
.. _format-menu:
174181

175182
Format menu (Editor window only)

Lib/idlelib/News3.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Released on 2026-10-01
44
=========================
55

66

7+
gh-152940: Add a Unicode character browser to IDLE. It appears on the
8+
Edit menu as "Character Browser" and can browse Unicode blocks, search
9+
for characters by name or code point, insert a character into the
10+
window, and copy a character to the clipboard. Patch by Serhiy
11+
Storchaka.
12+
713
gh-152745: When "Run... Customized" with "Restart shell" unchecked
814
while Shell is running code, including waiting for an input('prompt:')
915
response, just report that the shell is executing instead of

Lib/idlelib/charselect.py

Lines changed: 692 additions & 0 deletions
Large diffs are not rendered by default.

Lib/idlelib/editor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
138138
text.bind("<<find-selection>>", self.find_selection_event)
139139
text.bind("<<replace>>", self.replace_event)
140140
text.bind("<<goto-line>>", self.goto_line_event)
141+
text.bind("<<open-character-browser>>", self.open_character_browser)
141142
text.bind("<<smart-backspace>>",self.smart_backspace_event)
142143
text.bind("<<newline-and-indent>>",self.newline_and_indent_event)
143144
text.bind("<<smart-indent>>",self.smart_indent_event)
@@ -740,6 +741,11 @@ def open_path_browser(self, event=None):
740741
pathbrowser.PathBrowser(self.root)
741742
return "break"
742743

744+
def open_character_browser(self, event=None):
745+
from idlelib import charselect
746+
charselect.open(self)
747+
return "break"
748+
743749
def open_turtle_demo(self, event = None):
744750
import subprocess
745751

Lib/idlelib/idle_test/htest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@
7979
"Verify x.y.z versions and test each button, including Close.\n "
8080
}
8181

82+
CharSelectWindow_spec = {
83+
'file': 'charselect',
84+
'kwds': {'_htest': True},
85+
'msg': "Pick a block from the dropdown and scroll the grid.\n"
86+
"Click a character to see its details; double-click to copy it.\n"
87+
"Search for 'heart' or 'U+1F600' and press Go.\n"
88+
"Test the Copy buttons and verify the status bar feedback."
89+
}
90+
8291
# TODO implement ^\; adding '<Control-Key-\\>' to function does not work.
8392
_calltip_window_spec = {
8493
'file': 'calltip_w',

0 commit comments

Comments
 (0)