No project description provided
Project description
AsyncioPySide6
Empower Qt PySide6 developers with seamless async/await asynchronous programming capabilities
Installation:
pip install AsyncioPySide6
Example:
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QLabel
from AsyncioPySide6 import AsyncioPySide6
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.init_ui()
# Execute an asynchronous task
AsyncioPySide6.runTask(self.calculate_async(20))
def init_ui(self):
"""Initialize GUI"""
self.label = QLabel("Calculating...")
self.setCentralWidget(self.label)
async def calculate_async(self, n:int):
"""Asynchronous method that does a time-expensive calculation"""
# Give Qt sometime to show the window
await asyncio.sleep(0.5)
# Calculate
sum = 0
for i in range(n):
# Create some delay
await asyncio.sleep(0.1)
sum = sum + i
AsyncioPySide6.invokeInGuiThread(self, lambda: self._update_label(f"SUM([0..{i}]) = {sum}"))
def _update_label(self, text):
"""Updated GUI label, it must be ran in GUI thread"""
self.label.setText(text)
if __name__ == "__main__":
with AsyncioPySide6():
if not QApplication.instance():
app = QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
app.exec()
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
AsyncioPySide6-0.1.2.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file AsyncioPySide6-0.1.2.tar.gz.
File metadata
- Download URL: AsyncioPySide6-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85a9fefb954373117eb0d54a94216d573b5db88f7c04c0693cd6384cfa419684
|
|
| MD5 |
9960140d11783db647fa9149686ea383
|
|
| BLAKE2b-256 |
9b3640fdc5cbb40b3af872b9f9e0300cadecb6db401cb706b90cbb90a9781899
|
File details
Details for the file AsyncioPySide6-0.1.2-py3-none-any.whl.
File metadata
- Download URL: AsyncioPySide6-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fe1251a517000917920a788162a3037daa5bc14efb6db7ed2193765a2b64f32
|
|
| MD5 |
8cfac2c73802fa1bdf78f13f230b3c1d
|
|
| BLAKE2b-256 |
a056ed46c21ac279722d8874308178b314d582a8f396badb961c8c32a65655e5
|