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 PyQt5.QtCore import pyqtSignal, pyqtSlot
from autoqt 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

autoqt-0.0.6.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

autoqt-0.0.6-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file autoqt-0.0.6.tar.gz.

File metadata

  • Download URL: autoqt-0.0.6.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for autoqt-0.0.6.tar.gz
Algorithm Hash digest
SHA256 71c8dd8c8ed06b82a615c5a73d4492404c40de2989979ffca2af7aee2c000a01
MD5 3e8a0120b3e52bc9ee8f79d097937eb8
BLAKE2b-256 d2529bb3f1750c62f9c1e5eba6d7eb9702c81efb7b5a18fccbf31df6b5c7f769

See more details on using hashes here.

File details

Details for the file autoqt-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: autoqt-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for autoqt-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9fe481dfe9ae2bb905f131fa972fe5817c6993665b00ee283b89aa1b29ccff02
MD5 9a6dfc7d901753d8fd8d6ca42b737b54
BLAKE2b-256 10d3c10f747e9f8e2455ae94cfa01013388c3f1dbbb18de916c575562db68b5f

See more details on using hashes here.

Supported by

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