Skip to main content

Simplify pyqtProperty creation.

Project description



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

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


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):
        self._aNumber = 10
        self._otherNumber = 20
        self._aString = 'spam'

    def incrementNumber(self):
        self._aNumber += 1

    def otherNumber(self, value):
        self._otherNumber = value + 2

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.

Filename, size & hash SHA256 hash help File type Python version Upload date
autoqt-0.0.5-py3-none-any.whl (3.9 kB) Copy SHA256 hash SHA256 Wheel py3
autoqt-0.0.5.tar.gz (3.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page