From c682b75e2dbb67f41777b611959457ab9770d51d Mon Sep 17 00:00:00 2001 From: DevilXD Date: Fri, 19 Aug 2022 10:19:23 +0200 Subject: [PATCH] Minor naming and comments update --- gui.py | 14 +++++++------- main.py | 4 ++-- twitch.py | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gui.py b/gui.py index bc63655..97088db 100644 --- a/gui.py +++ b/gui.py @@ -1621,7 +1621,7 @@ class GUIManager: def __init__(self, twitch: Twitch): self._twitch: Twitch = twitch self._poll_task: asyncio.Task[NoReturn] | None = None - self._closed = asyncio.Event() + self._close_requested = asyncio.Event() self._root = root = Tk() # withdraw immediately to prevent the window from flashing self._root.withdraw() @@ -1744,14 +1744,14 @@ class GUIManager: @property def close_requested(self) -> bool: - return self._closed.is_set() + return self._close_requested.is_set() async def wait_until_closed(self): # wait until the user closes the window - await self._closed.wait() + await self._close_requested.wait() def prevent_close(self): - self._closed.clear() + self._close_requested.clear() def start(self): if self._poll_task is None: @@ -1783,12 +1783,12 @@ class GUIManager: def close(self): """ - Requests the application to close. + Requests the GUI application to close. The window itself will be closed in the closing sequence later. """ - self._closed.set() + self._close_requested.set() # notify client we're supposed to close - self._twitch.request_close() + self._twitch.close() def close_window(self): """ diff --git a/main.py b/main.py index 691c07b..a00104f 100644 --- a/main.py +++ b/main.py @@ -160,8 +160,8 @@ exit_status = 0 loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) client = Twitch(settings) -signal.signal(signal.SIGINT, lambda *_: client.close()) -signal.signal(signal.SIGTERM, lambda *_: client.close()) +signal.signal(signal.SIGINT, lambda *_: client.signal_close()) +signal.signal(signal.SIGTERM, lambda *_: client.signal_close()) try: loop.run_until_complete(client.run()) except CaptchaRequired: diff --git a/twitch.py b/twitch.py index df97d2d..8a55a01 100644 --- a/twitch.py +++ b/twitch.py @@ -121,14 +121,15 @@ class Twitch: # perfect for GUI usage return partial(self.change_state, state) - def close(self): + def signal_close(self): """ Called when the application is requested to close by the operating system, usually by receiving a SIGINT or SIGTERM. """ + # delegate this to the same action as the user clicking on the X in the GUI window self.gui.close() - def request_close(self): + def close(self): """ Called when the application is requested to close by the user, usually by the console or application window being closed.