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

Note:

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')
        self.signal.connect(self.after)
        self.file.write('before')

    def after(self, value):
        self.signal.disconnect(self.after)
        self.file.write(f'after {value!r}')
        self.file.close()
async def together(a_signal):
    with open(self.some_path, 'w') as file:
        async with qtrio.enter_emissions_channel(signals=[a_signal]) as emissions:
            file.write('before')
            emission = await emissions.channel.receive()
            [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.

Source Distribution

qtrio-0.1.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qtrio-0.1.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file qtrio-0.1.0.tar.gz.

File metadata

  • Download URL: qtrio-0.1.0.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for qtrio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7005d2d558f28c6420fd3ceb7205e2f3230da56b510a71752189ba8960b40882
MD5 57bcf9ae8fd4151546dfef99ad1e5d25
BLAKE2b-256 223d67cb5002f17ee6b7ce5fec5dce76e41b718722145032deebbdd49a6af111

See more details on using hashes here.

File details

Details for the file qtrio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qtrio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for qtrio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6461ac2a9c13011a2c8b45b174f497cc1f50bd88bc62bcb92a9f64763cced35e
MD5 139d205793dc6ca6c228b6cb111d6708
BLAKE2b-256 c8088f98b021190d5acf51ac6fdb4d3ce3fdcde633a865ba128429887cf9ae46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page