Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-111050: IDLE - Simplify configdialog.HighPage.theme_elements #111053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions 44 Lib/idlelib/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,24 +576,23 @@ def create_page_highlight(self):
(*)theme_message: Label
"""
self.theme_elements = {
# Display_name: ('internal_name, sort_number').
# TODO: remove sort_number unneeded with dict ordering.
'Normal Code or Text': ('normal', '00'),
'Code Context': ('context', '01'),
'Python Keywords': ('keyword', '02'),
'Python Definitions': ('definition', '03'),
'Python Builtins': ('builtin', '04'),
'Python Comments': ('comment', '05'),
'Python Strings': ('string', '06'),
'Selected Text': ('hilite', '07'),
'Found Text': ('hit', '08'),
'Cursor': ('cursor', '09'),
'Editor Breakpoint': ('break', '10'),
'Shell Prompt': ('console', '11'),
'Error Text': ('error', '12'),
'Shell User Output': ('stdout', '13'),
'Shell User Exception': ('stderr', '14'),
'Line Number': ('linenumber', '16'),
# Display-name: internal-config-tag-name.
'Normal Code or Text': 'normal',
'Code Context': 'context',
'Python Keywords': 'keyword',
'Python Definitions': 'definition',
'Python Builtins': 'builtin',
'Python Comments': 'comment',
'Python Strings': 'string',
'Selected Text': 'hilite',
'Found Text': 'hit',
'Cursor': 'cursor',
'Editor Breakpoint': 'break',
'Shell Prompt': 'console',
'Error Text': 'error',
'Shell User Output': 'stdout',
'Shell User Exception': 'stderr',
'Line Number': 'linenumber',
}
self.builtin_name = tracers.add(
StringVar(self), self.var_changed_builtin_name)
Expand Down Expand Up @@ -653,7 +652,7 @@ def tem(event, elem=element):
# event.widget.winfo_top_level().highlight_target.set(elem)
self.highlight_target.set(elem)
text.tag_bind(
self.theme_elements[element][0], '<ButtonPress-1>', tem)
self.theme_elements[element], '<ButtonPress-1>', tem)
text['state'] = 'disabled'
self.style.configure('frame_color_set.TFrame', borderwidth=1,
relief='solid')
Expand Down Expand Up @@ -761,7 +760,6 @@ def load_theme_cfg(self):
self.set_theme_type()
# Load theme element option menu.
theme_names = list(self.theme_elements)
theme_names.sort(key=lambda x: self.theme_elements[x][1])
self.targetlist.SetMenu(theme_names, theme_names[0])
self.paint_theme_sample()
self.set_highlight_target()
Expand Down Expand Up @@ -888,7 +886,7 @@ def on_new_color_set(self):
new_color = self.color.get()
self.style.configure('frame_color_set.TFrame', background=new_color)
plane = 'foreground' if self.fg_bg_toggle.get() else 'background'
sample_element = self.theme_elements[self.highlight_target.get()][0]
sample_element = self.theme_elements[self.highlight_target.get()]
self.highlight_sample.tag_config(sample_element, **{plane: new_color})
theme = self.custom_name.get()
theme_element = sample_element + '-' + plane
Expand Down Expand Up @@ -1002,7 +1000,7 @@ def set_color_sample(self):
frame_color_set
"""
# Set the color sample area.
tag = self.theme_elements[self.highlight_target.get()][0]
tag = self.theme_elements[self.highlight_target.get()]
plane = 'foreground' if self.fg_bg_toggle.get() else 'background'
color = self.highlight_sample.tag_cget(tag, plane)
self.style.configure('frame_color_set.TFrame', background=color)
Expand Down Expand Up @@ -1032,7 +1030,7 @@ def paint_theme_sample(self):
else: # User theme
theme = self.custom_name.get()
for element_title in self.theme_elements:
element = self.theme_elements[element_title][0]
element = self.theme_elements[element_title]
colors = idleConf.GetHighlight(theme, element)
if element == 'cursor': # Cursor sample needs special painting.
colors['background'] = idleConf.GetHighlight(
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/idlelib/idle_test/test_configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def test_highlight_target_text_mouse(self):

def tag_to_element(elem):
for element, tag in d.theme_elements.items():
elem[tag[0]] = element
elem[tag] = element

def click_it(start):
x, y, dx, dy = hs.bbox(start)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.