How to use qasync - 1 common examples

To help you get started, we’ve selected a few qasync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github almarklein / wgpu-py / visvis2 / _figure.py View on Github external
def paintEngine(self):
        # https://doc.qt.io/qt-5/qt.html#WidgetAttribute-enum  WA_PaintOnScreen
        return None


app = QtWidgets.QApplication([])


# %% Integrate QT with asyncio


if False:
    # The qasync way, probably the best way, but needs a new event loop, so
    # does not integrate so well (yet) with IDE's.
    loop = qasync.QEventLoop(app)
    asyncio.set_event_loop(loop)

    # An experimental Pyzo thing I hacked together to switch loops
    if hasattr(asyncio, "integrate_with_ide"):
        asyncio.integrate_with_ide(loop, run=False)
else:
    # The quick-n-dirty way, simple and effective, but this limits the
    # rate in which qt can process events. If we could get an event
    # when qt has pending events, this might actually be effective.
    async def _keep_qt_alive():
        while True:
            await asyncio.sleep(0.01)
            app.flush()
            app.processEvents()

    asyncio.get_event_loop().create_task(_keep_qt_alive())

qasync

Python library for using asyncio in Qt-based applications

BSD-2-Clause
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis

Popular qasync functions