Skip to main content

Simplify pyqtProperty creation.

Project description

autoqt

PyPI Build Status

A simple single file module that makes setting up basic Qt properties a little bit nicer without restricting you.

This is very useful if you have QObjects with many readonly properties and a few special setters or state modifying slots.

Example:

from PyQt6.QtCore import pyqtSignal, pyqtSlot
from autoqt6 import AutoObject, AutoProp


class SomeObject(AutoObject):
    valuesChanged = pyqtSignal()

    aNumber = AutoProp(int, 'valuesChanged', '_aNumber')
    otherNumber = AutoProp(float, 'valuesChanged', '_otherNumber')
    aString = AutoProp(str, 'valuesChanged', '_aString', write=True)

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self._aNumber = 10
        self._otherNumber = 20
        self._aString = 'spam'

    @pyqtSlot()
    def incrementNumber(self):
        self._aNumber += 1
        self.valuesChanged.emit()

    @otherNumber.setter
    def otherNumber(self, value):
        self._otherNumber = value + 2
        self.valuesChanged.emit()


x = SomeObject()

print(x.aNumber)  # 10
x.aNumber = 10  # throws AttributeError, readonly property
x.incrementNumber()  # valuesChanged is emitted
print(x.aNumber)  # 11

print(x.otherNumber)  # 20
x.otherNumber = 40  #  otherNumber.setter called, valuesChanged is emitted
print(x.otherNumber)  # 42

print(x.aString)  # 'spam'
x.aString = 'ham'  # valuesChanged is emitted, writable property
print(x.aString)  # 'ham'

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

autoqt6-0.0.8.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

autoqt6-0.0.8-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file autoqt6-0.0.8.tar.gz.

File metadata

  • Download URL: autoqt6-0.0.8.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for autoqt6-0.0.8.tar.gz
Algorithm Hash digest
SHA256 91b575eea61be5552bd1eb562e07de2ccac037f2506de3c1c80a9da196daba14
MD5 271807a19e97a732502e5938a82c3a13
BLAKE2b-256 bb49c5c0b3432800303acc744646ccd23329a24345a1bc4271653fcbc5f9f985

See more details on using hashes here.

File details

Details for the file autoqt6-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: autoqt6-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for autoqt6-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 62fd885edbc04531f52881260a974d848c7b2b8c2eb5683c5cbe7a6d0e37ecca
MD5 226de5fce298046e1c82673f7225c075
BLAKE2b-256 5e74109a97c495e182c85f39d4c3efc4f75e08d9fcbbe043d9ddf5bd82f8fa71

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