Skip to main content

trio-gtk

Build Status

Trio guest mode wrapper for PyGTK

Using the Trio guest mode feature, we can run both the Trio and PyGTK event loops alongside each other in a single program. This allows us to make use of the Trio library and the usual async/await syntax and not have to directly manage thread pools. This library provides a thin wrapper for initialising the guest mode and exposes a single public API function, trio_gtk.run into which you can pass your Trio main function.

Install

$ pip install trio-gtk

Please note, trio-gtk does install pygobject directly as a Python package. We use relaxed bounds to ensure that the hard dependency on system packages (see cairo integration documentation will not stop you having a successful installation. This may not always work out. If you see a build error during your Pip installation, please raise a ticket and we will see what we can do.

Example

import gi
import trio

gi.require_version("Gtk", "3.0")

from gi.repository import Gtk as gtk

import trio_gtk


class Example(gtk.Window):
    def __init__(self, nursery):
        gtk.Window.__init__(self, title="Example")

        self.button = gtk.Button(label="Create a task")
        self.button.connect("clicked", self.on_click)
        self.add(self.button)

        self.counter = 0
        self.nursery = nursery

        self.connect("destroy", gtk.main_quit)
        self.show_all()

    def on_click(self, widget):
        self.counter += 1
        self.nursery.start_soon(self.say_hi, self.counter)

    async def say_hi(self, count):
        while True:
            await trio.sleep(1)
            print(f"hi from task {count}")


async def main():
    async with trio.open_nursery() as nursery:
        Example(nursery)
        await trio.sleep_forever()


trio_gtk.run(main)

Metadata

Release files for trio-gtk 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trio-gtk 3.0.0
File Size Uploaded Provenance
trio-gtk-3.0.0.tar.gz 15.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for trio-gtk 3.0.0
File Interpreter ABI Platform
trio_gtk-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.2 kB

Release files / trio-gtk-3.0.0.tar.gz

Download URL trio-gtk-3.0.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e462512596b3d023b3f093497fc433f67957816284f7761bd6324930472ed4d3
BLAKE2b-256 checksum
How to use checksums
c8df8c8bf5821c5d420fda571a9e301e8c8be2b21f3fa3afeea3e01e8d022323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/3.8.0 Linux/4.9.0-13-amd64

Release files / trio_gtk-3.0.0-py3-none-any.whl

Download URL trio_gtk-3.0.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc101157af1f4b60db580930c31b58dec6fcaa58c69e3b26ed5e3b01edac4926
BLAKE2b-256 checksum
How to use checksums
eb266252a04a51ac1974ae84e7074327abd4b2fe057f53fb8a4dd99be796a4e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/3.8.0 Linux/4.9.0-13-amd64

Security for trio-gtk 3.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page