Browse Source

Yeehaw asyncio glib cowgirls

unifiedWindowUI
Luke Murphy 4 years ago
parent
commit
ad73f87cc5
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 14
      dropship.py
  2. 2
      requirements.txt

14
dropship.py

@ -18,6 +18,7 @@ asyncio.set_event_loop_policy(asyncio_glib.GLibEventLoopPolicy())
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
log = logging.getLogger("dropship") log = logging.getLogger("dropship")
loop = asyncio.get_event_loop()
class DropShip: class DropShip:
@ -27,6 +28,8 @@ class DropShip:
self.GLADE_FILE = "dropship.glade" self.GLADE_FILE = "dropship.glade"
self.CSS_FILE = "dropship.css" self.CSS_FILE = "dropship.css"
self._running = loop.create_future()
self.init_glade() self.init_glade()
self.init_css() self.init_css()
self.init_drop_box() self.init_drop_box()
@ -51,7 +54,7 @@ class DropShip:
"""Initialise the GUI window.""" """Initialise the GUI window."""
self.main_window_id = "mainWindow" self.main_window_id = "mainWindow"
self.window = self.builder.get_object(self.main_window_id) 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() self.window.show()
def init_drop_box(self): def init_drop_box(self):
@ -80,11 +83,16 @@ class DropShip:
self.dropLabel.set_text("Sending..") self.dropLabel.set_text("Sending..")
self.files_to_send = files self.files_to_send = files
def on_quit(self, *args, **kwargs):
self.window.close()
self._running.set_result(None)
async def main(): async def main():
"""The application entrypoint.""" """The application entrypoint."""
DropShip() dropship = DropShip()
await dropship._running
if __name__ == "__main__": if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main()) loop.run_until_complete(main())

2
requirements.txt

@ -1,3 +1,3 @@
PyGObject==3.36.1 PyGObject==3.36.1
asyncio-glib==0.1 -e git+https://github.com/decentral1se/asyncio-glib#egg=asyncio-glib
magic-wormhole==0.12.0 magic-wormhole==0.12.0

Loading…
Cancel
Save