From ad73f87cc55e5ef0f7d48e870e6c2a3b3f9aff91 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Wed, 22 Jul 2020 18:56:26 +0200 Subject: [PATCH] Yeehaw asyncio glib cowgirls --- dropship.py | 14 +++++++++++--- requirements.txt | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dropship.py b/dropship.py index 8609481..e6a3b94 100644 --- a/dropship.py +++ b/dropship.py @@ -18,6 +18,7 @@ asyncio.set_event_loop_policy(asyncio_glib.GLibEventLoopPolicy()) logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) log = logging.getLogger("dropship") +loop = asyncio.get_event_loop() class DropShip: @@ -27,6 +28,8 @@ class DropShip: self.GLADE_FILE = "dropship.glade" self.CSS_FILE = "dropship.css" + self._running = loop.create_future() + self.init_glade() self.init_css() self.init_drop_box() @@ -51,7 +54,7 @@ class DropShip: """Initialise the GUI window.""" self.main_window_id = "mainWindow" self.window = self.builder.get_object(self.main_window_id) - self.window.connect("delete-event", gtk.main_quit) + self.window.connect("delete-event", self.on_quit) self.window.show() def init_drop_box(self): @@ -80,11 +83,16 @@ class DropShip: self.dropLabel.set_text("Sending..") self.files_to_send = files + def on_quit(self, *args, **kwargs): + self.window.close() + self._running.set_result(None) + async def main(): """The application entrypoint.""" - DropShip() + dropship = DropShip() + await dropship._running if __name__ == "__main__": - asyncio.get_event_loop().run_until_complete(main()) + loop.run_until_complete(main()) diff --git a/requirements.txt b/requirements.txt index e34c204..4bd3455 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ PyGObject==3.36.1 -asyncio-glib==0.1 +-e git+https://github.com/decentral1se/asyncio-glib#egg=asyncio-glib magic-wormhole==0.12.0