From 520ff5868fddd339c10a80800c242f6ef8ff3cc4 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 20 Feb 2022 19:05:41 +0000 Subject: [PATCH] theme.py: Apply .configure() paranoia on button enter/leave --- theme.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/theme.py b/theme.py index ce9318bd..4f60f976 100644 --- a/theme.py +++ b/theme.py @@ -195,17 +195,35 @@ class _Theme(object): def _enter(self, event, image): widget = event.widget if widget and widget['state'] != tk.DISABLED: - widget.configure(state=tk.ACTIVE) + try: + widget.configure(state=tk.ACTIVE) + + except Exception: + logger.exception(f'Failure setting widget active: {widget=}') + if image: - image.configure(foreground=self.current['activeforeground'], - background=self.current['activebackground']) + try: + image.configure(foreground=self.current['activeforeground'], + background=self.current['activebackground']) + + except Exception: + logger.exception(f'Failure configuring image: {image=}') def _leave(self, event, image): widget = event.widget if widget and widget['state'] != tk.DISABLED: - widget.configure(state=tk.NORMAL) + try: + widget.configure(state=tk.NORMAL) + + except Exception: + logger.exception(f'Failure setting widget normal: {widget=}') + if image: - image.configure(foreground=self.current['foreground'], background=self.current['background']) + try: + image.configure(foreground=self.current['foreground'], background=self.current['background']) + + except Exception: + logger.exception(f'Failure configuring image: {image=}') # Set up colors def _colors(self, root, theme):