Skip to main content

a library bringing Qt GUIs together with ``async`` and ``await`` via Trio

Project description

Join chatroom Join forum Documentation Latest PyPi version Repository Test coverage

QTrio - a library bringing Qt GUIs together with async and await via Trio

This library is in early development. It works. It has tests. It has documentation. Expect breaking changes as we explore a clean API. By paying this price you get the privilege to provide feedback via GitHub issues to help shape our future. :]

The QTrio project’s goal is to bring the friendly concurrency of Trio using Python’s async and await syntax together with the GUI features of Qt to enable more correct code and a more pleasant developer experience. QTrio is permissively licensed to avoid introducing restrictions beyond those of the underlying Python Qt library you choose. Both PySide2 and PyQt5 are supported.

By enabling use of async and await it is possible in some cases to write related code more concisely and clearly than you would get with the signal and slot mechanisms of Qt concurrency.

class TwoStep:
    def __init__(self, a_signal, some_path):
        self.signal = a_signal
        self.file = None
        self.some_path = some_path

    def before(self):
        self.file = open(some_path, 'w')

    def after(self, value):
        self.file.write(f'after {value!r}')
async def together(a_signal):
    with open(self.some_path, 'w') as file:
        async with qtrio.enter_emissions_channel(signals=[a_signal]) as emissions:
            emission = await
            [value] = emission.args
            file.write(f'after {value!r}')

Note how by using async and await we are not only able to more clearly and concisely describe the sequenced activity, we also get to use with to manage the context of the open file to be sure it gets closed.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for qtrio, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size qtrio-0.1.0-py3-none-any.whl (28.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size qtrio-0.1.0.tar.gz (32.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page