jvconnected.ui.utils
- class jvconnected.ui.utils.GenericQObject[source]
Bases:
QObject
Utility class to remove some of the boilerplate code needed to implement
Property
attributes.The intended pattern uses the following naming convention:
class MyQtObject(GenericQObject): _n_fooValue = Signal() # The 'notify' signal to emit on changes def __init__(self, *args): self._fooValue = 0 # The instance attribute containing the value def _get_fooValue(self): return self._fooValue def _set_fooValue(self, value): self._generic_setter('_fooValue', value) fooValue = Property(_get_fooValue, _set_fooValue, notify=_n_fooValue)
- jvconnected.ui.utils.connect_close_event(f: Callable)[source]
Connect the app
aboutToQuit
signal to the provided callback function
- jvconnected.ui.utils.AnnotatedQtSignal(**kwargs)[source]
Allows
Signal
methods to be annotated with arguments and typesThe keyword arguments should be in the form of
AnnotatedQtSignal(arg_name=arg_type)
from PySide2.QtCore import QObject, Signal from jvconnected.ui.utils import AnnotatedQtSignal as AnnoSignal class MyObject(QObject): my_signal: AnnoSignal(name=str, value=int) = Signal(str, int) '''Description of ``my_signal``'''
This allows a custom Sphinx extension to include the annotated argument names with their types (as a normal method would appear) instead of the types only.
Note
This does not yet support type checking and will very likely fail against MyPy checks. It only exists for documentation purposes.