From 9672a961d025222e2656a22bb064b6eefc251f70 Mon Sep 17 00:00:00 2001 From: David Hozic Date: Thu, 12 Sep 2024 20:55:38 +0200 Subject: [PATCH 1/3] Fixed exception when printing toasts --- src/daf_gui/main.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/daf_gui/main.py b/src/daf_gui/main.py index c8d6cf68..ee34acbd 100644 --- a/src/daf_gui/main.py +++ b/src/daf_gui/main.py @@ -149,9 +149,17 @@ def init_event_listeners(self): } dpi_78, dpi_600 = dpi_scaled(78), dpi_scaled(600) + last_toast: ToastNotification = None def trace_listener(level: daf.TraceLEVELS, message: str): - last_toast: ToastNotification = ToastNotification.last_toast - if last_toast is not None and last_toast.toplevel.winfo_exists(): + nonlocal last_toast + + if last_toast is None: + next_position = dpi_78 + elif last_toast.toplevel is None or last_toast.toplevel.winfo_exists(): + # If toplevel is None, that means that tkinter re-entered the its event loop in the + # toast.show_toast() call before that same function was able to set the toplevel attribute. + # This happens due to ttkbootstrap library providing the 'alpha' parameter to Tkinter's TopLevel class, + # which causes Tkinter to re-enter its event loop and process another after_idle(trace_listener, ...) command. next_position = max((last_toast.position[1] + dpi_78) % dpi_600, dpi_78) else: next_position = dpi_78 @@ -165,10 +173,9 @@ def trace_listener(level: daf.TraceLEVELS, message: str): position=(10, next_position, "se"), topmost=True ) - ToastNotification.last_toast = toast + last_toast = toast toast.show_toast() - ToastNotification.last_toast = None evt = daf.get_global_event_ctrl() evt.add_listener( daf.EventID.g_trace, lambda level, message: self.win_main.after_idle(trace_listener, level, message) From ef2b7cecb149e860bea0adac6f3eb93f10876195 Mon Sep 17 00:00:00 2001 From: David Hozic Date: Thu, 12 Sep 2024 20:56:46 +0200 Subject: [PATCH 2/3] Changelog --- docs/source/changelog.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 79e68e24..65f60bd0 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -50,7 +50,8 @@ v4.1.0 information. - Fixed SQL log removal through the GUI. - Fixed CSV and JSON reading through remote. -- Disabled the :ref:`Automatic guild discovery and join` features due to the search provider shutting down its +- Fixed exception when GUI tried to print a message. +- |BREAK_CH| Disabled the :ref:`Automatic guild discovery and join` features due to the search provider shutting down its services. It will be reenabled in a future version. From 33618f8fb69c51cb4c11b8e63c22c5daf2b48cc3 Mon Sep 17 00:00:00 2001 From: David Hozic Date: Thu, 12 Sep 2024 21:11:35 +0200 Subject: [PATCH 3/3] Fix docs --- src/daf/message/messageperiod.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/daf/message/messageperiod.py b/src/daf/message/messageperiod.py index b1447010..c94f168f 100644 --- a/src/daf/message/messageperiod.py +++ b/src/daf/message/messageperiod.py @@ -300,7 +300,7 @@ class NamedDayOfYearPeriod(EveryXPeriod): ---------- .. code-block:: python - # Every second monday of December at 12:00. + # Every second Monday of December at 12:00. NamedDayOfYearPeriod( time=time(hour=12), # Time day="Mon", # Day (Monday) @@ -377,8 +377,6 @@ class NamedDayOfMonthPeriod(EveryXPeriod): The day of week when to send. week: int The week number of which to send. E.g., 1 for 1st week, 2 for second week. - month: 1 - 12 - The month in which to send. next_send_time: datetime | timedelta Represents the time at which the message should first be sent. Use ``datetime`` to specify the exact date and time at which the message should start being sent. @@ -389,12 +387,11 @@ class NamedDayOfMonthPeriod(EveryXPeriod): ---------- .. code-block:: python - # Every second monday of December at 12:00. - NamedDayOfYearPeriod( + # Second Monday of every month at 12:00. + NamedDayOfMonthPeriod( time=time(hour=12), # Time day="Mon", # Day (Monday) week=2, # Which week (second monday) - month=12 # Month (December) ) """ DAYS = Literal["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]