Skip to main content

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__":
    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.2.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AsyncioPySide6-0.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file AsyncioPySide6-0.2.0.tar.gz.

File metadata

  • Download URL: AsyncioPySide6-0.2.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for AsyncioPySide6-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c6c9c653f35441f718ff3700a69b171a71891a3e201679712021a535da5a0124
MD5 951c79b8c8ae463ef0b610d13f3a734b
BLAKE2b-256 36150506bd35b22fc5e7858de67ada2e807a8a55ef9dbfcccab7401f5abaf08f

See more details on using hashes here.

File details

Details for the file AsyncioPySide6-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: AsyncioPySide6-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for AsyncioPySide6-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94a41ac20fa0e1f1b37819da3408d6fb708c382dbb18b7871a8f6f9dbeeeb467
MD5 a9f9c8410d3d7c99981c01523aa35ef2
BLAKE2b-256 4f0d1e34fc66d9a1b2d34fe482adbbf847822d323035a57ee8c1e6bc64920254

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page