From e1182ec42af2f3d473d2296d970a5e63911cda22 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Fri, 4 Oct 2024 12:29:11 +0200 Subject: [PATCH] --amend --- examples/gui_qt_asyncio.py | 15 +++++++++++---- examples/gui_qt_embed.py | 4 +--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/gui_qt_asyncio.py b/examples/gui_qt_asyncio.py index 7beb6fe5..77dc652d 100644 --- a/examples/gui_qt_asyncio.py +++ b/examples/gui_qt_asyncio.py @@ -3,6 +3,12 @@ This is the same as the ``gui_qt_embed.py`` example, except this uses the asyncio compatible mode that was introduced in Pyside 6.6. + +For more info see: + +* https://doc.qt.io/qtforpython-6/PySide6/QtAsyncio/index.html +* https://www.qt.io/blog/introducing-qtasyncio-in-technical-preview + """ # ruff: noqa: N802 @@ -28,14 +34,15 @@ def __init__(self): self.canvas = WgpuWidget(splitter) self.output = QtWidgets.QTextEdit(splitter) - # self.button.clicked.connect(self.whenButtonClicked) + # With QtAsyncio, the callbacks can now return a future. You'd + # think that you could also return a coro, but we need to wrap + # it into a future, making this code a bit ugly. + # self.button.clicked.connect(self.whenButtonClicked) # why not :/ self.button.clicked.connect( lambda: asyncio.ensure_future(self.whenButtonClicked()) ) - splitter.addWidget( - self.canvas, - ) + splitter.addWidget(self.canvas) splitter.addWidget(self.output) splitter.setSizes([400, 300]) diff --git a/examples/gui_qt_embed.py b/examples/gui_qt_embed.py index 2227bd78..41e919ec 100644 --- a/examples/gui_qt_embed.py +++ b/examples/gui_qt_embed.py @@ -37,9 +37,7 @@ def __init__(self): self.button.clicked.connect(self.whenButtonClicked) - splitter.addWidget( - self.canvas, - ) + splitter.addWidget(self.canvas) splitter.addWidget(self.output) splitter.setSizes([400, 300])