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
self.label.setText(f"SUM([0..{i}]) = {sum}")
def _update_label(self, text):
"""Updated GUI label, it must be ran in GUI thread"""
if __name__ == "__main__":
app = QApplication(sys.argv)
with AsyncioPySide6.use_asyncio():
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.3.1.tar.gz
(4.7 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.3.1.tar.gz.
File metadata
- Download URL: AsyncioPySide6-0.3.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d65fb3d807bb50595244bf37b4815d19631f8c76359b9d39d278871a3bcd82a
|
|
| MD5 |
699aaf32031e4e8ad69e76c417d14756
|
|
| BLAKE2b-256 |
1f412cb577b6380a2cedf6b52350373149d5c15ea2fde8e64422eeb5a6dc8f24
|
File details
Details for the file AsyncioPySide6-0.3.1-py3-none-any.whl.
File metadata
- Download URL: AsyncioPySide6-0.3.1-py3-none-any.whl
- Upload date:
- Size: 8.5 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 |
3eb24e2ce2d21b19db22181c16ab4a0e7cfe5b071c2c4342df2f4e2d35e4dcfa
|
|
| MD5 |
9387a25d72d7c05f4d459d5febd36fb8
|
|
| BLAKE2b-256 |
07e8ca7514989991b8d3530651c376b1477d45d7d8fd335d6e686e510f5fcf35
|