Add better error handling and quiting

This commit is contained in:
Luke Murphy 2020-09-20 23:45:24 +02:00
parent 6849388f59
commit 6cd445e54d
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,8 @@
# trio-gtk 0.1.1 (2020-09-20)
- Fix traceback handling on `done_callback`.
- Exit gracefully calling `gtk.main_quit` directly.
# trio-gtk 0.1.0 (2020-09-20)
- Initial pre-alpha release.

View File

@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"
[tool.poetry]
name = "trio-gtk"
version = "0.1.0"
version = "0.1.1"
description = "Trio guest mode wrapper for PyGTK"
authors = ["decentral1se <lukewm@riseup.net>"]
maintainers = ["decentral1se <lukewm@riseup.net>"]

View File

@ -1,3 +1,5 @@
import traceback
import gi
import trio
@ -5,6 +7,7 @@ gi.require_version("Gtk", "3.0")
from gi.repository import GLib as glib
from gi.repository import Gtk as gtk
from outcome import Error
__all__ = ["run"]
@ -19,7 +22,10 @@ def run(trio_main):
await trio.sleep(1)
def done_callback(outcome):
glib.idle_add(gtk.main_quit)
if isinstance(outcome, Error):
exc = outcome.error
traceback.print_exception(type(exc), exc, exc.__traceback__)
gtk.main_quit()
def glib_schedule(function):
glib.idle_add(function)