Skip to content

Commit

Permalink
theme: Only try to set foreground if the widget has it
Browse files Browse the repository at this point in the history
This tripped up on a `ttk.Sizegrip`, so add the same `'foreground' in
widget.keys()` style of check as other code in this function.
  • Loading branch information
Athanasius committed Dec 26, 2023
1 parent 0137944 commit 778063c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,18 @@ def _update_widget(self, widget: tk.Widget | tk.BitmapImage) -> None: # noqa: C

elif 'cursor' in widget.keys() and str(widget['cursor']) not in ['', 'arrow']:
# Hack - highlight widgets like HyperlinkLabel with a non-default cursor
if 'fg' not in attribs:
widget['foreground'] = self.current['highlight']
if 'fg' not in attribs and 'foreground' in widget.keys():
widget.configure(foreground=self.current['highlight']),
if 'insertbackground' in widget.keys(): # tk.Entry
widget['insertbackground'] = self.current['foreground']

if 'bg' not in attribs:
widget['background'] = self.current['background']
if 'bg' not in attribs and 'background' in widget.keys():
widget.configure(background=self.current['background'])
if 'highlightbackground' in widget.keys(): # tk.Entry
widget['highlightbackground'] = self.current['background']

if 'font' not in attribs:
widget['font'] = self.current['font']
if 'font' not in attribs and 'font' in widget.keys():
widget.configure(font=self.current['font'])

elif 'activeforeground' in widget.keys():
# e.g. tk.Button, tk.Label, tk.Menu
Expand Down

0 comments on commit 778063c

Please sign in to comment.