Yeehaw asyncio glib cowgirls

This commit is contained in:
Luke Murphy 2020-07-22 18:56:26 +02:00
parent 1e3ddc86a7
commit ad73f87cc5
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 12 additions and 4 deletions

View File

@ -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())

View File

@ -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