Details
-
Suggestion
-
Resolution: Duplicate
-
P3: Somewhat important
-
None
-
None
-
None
Description
There is a Python module called Quamash which integrates Qt's event loop with asyncio's. With it, you can use Python async/await functions (and any other library using asyncio) in your PySide/PyQt application.
UPDATE: Another module called asyncqt based on quamash appeared, which apply the same idea but for newer versions of Qt.
I think it would be pretty cool if, in supported python versions, you could await a signal instead of using connect(callback). Like in this contrived example with the clicked signal on QPushButton, you can do this instead of button.clicked.connect(lambda: print("Button clicked!")):
async def my_function(): await button.clicked.future() print("Button clicked!")
Under the hood it'd connect a simple callback to the signal that gets disconnected after the future is done.
For signals that take callbacks that have more than one argument, it'd have to return a tuple that you can unpack like this:
(foo, bar, baz) = await some_obj.some_signal.future()
I imagine there are more possibilities for asyncio integration, so this issue could be a brainstorming thread for that too. (perhaps a version of Quamash made in C++ for tighter Qt integration could come with PySide?)
Attachments
Issue Links
- duplicates
-
PYSIDE-769 Qt for Python asynchronous support
- Open