Data field widgets

dawiq.fieldwidgets provides widgets to represent the fields of the dataclass. Widgets are compatible to dawiq.typing.FieldWidgetProtocol.

class dawiq.fieldwidgets.BoolCheckBox(*args: Any, **kwargs: Any)[source]

Bases: QCheckBox

Checkbox for fuzzy boolean value.

Check state of the box represents the field value. If the box is checked, the value is True. If unchecked, the value is False.

If tristate is enabled, setting None as the field value sets the state as Qt.PartiallyChecked. If tristate is disabled, None is treated as False and unchecks the box.

fieldValueChanged

alias of object

class dawiq.fieldwidgets.EmptyIntValidator(*args: Any, **kwargs: Any)[source]

Bases: QIntValidator

Validator which accpets integer and empty string

class dawiq.fieldwidgets.IntLineEdit(*args: Any, **kwargs: Any)[source]

Bases: QLineEdit

Line edit for integer value.

If the text is not empty, the field value is the integer that the text is converted to. If the line edit is empty or the text cannot be converted to integer, None is the field value. Setting None as field value clears the line edit.

fieldValueChanged

alias of object

class dawiq.fieldwidgets.EmptyFloatValidator(*args: Any, **kwargs: Any)[source]

Bases: QDoubleValidator

Validator which accpets float and empty string

class dawiq.fieldwidgets.FloatLineEdit(*args: Any, **kwargs: Any)[source]

Bases: QLineEdit

Line edit for float value.

If the text is not empty, the field value is the float that the text is converted to. If the line edit is empty or the text cannot be converted to float, None is the field value. Setting None as field value clears the line edit.

fieldValueChanged

alias of object

class dawiq.fieldwidgets.StrLineEdit(*args: Any, **kwargs: Any)[source]

Bases: QLineEdit

Line edit for string value.

If the line edit is empty, field data is empty string. Setting None as the field value clears the widget.

fieldValueChanged

alias of str

class dawiq.fieldwidgets.EnumComboBox(*args: Any, **kwargs: Any)[source]

Bases: QComboBox

Combo box for enum.Enum type.

Standard way to construct this widget is by fromEnum() class method. N-th item contains N-th member of the Enum as its data.

Enum instance is stored in item data. Field value is the data of currently activated item. If the current index is -1, field value is None.

fieldValueChanged

alias of object

class dawiq.fieldwidgets.TupleGroupBox(*args: Any, **kwargs: Any)[source]

Bases: QGroupBox

Group box for tuple with fixed length.

This is the group box which contains field widgets as subwidgets. Field value is the tuple of subwidgets values.

fieldValueChanged

alias of tuple

orientation() dawiq.qt_compat.QtCore.Qt.Orientation[source]

Orientation to stack the subwidgets.

count() int[source]

Number of subwidgets.

widget(index: int) FieldWidgetProtocol | None[source]

Returns the subwidget at the given index, or None for invalid index.

insertWidget(index: int, widget: FieldWidgetProtocol, stretch: int = 0, alignment: dawiq.qt_compat.QtCore.Qt.AlignmentFlag = dawiq.qt_compat.QtCore.Qt.AlignmentFlag)[source]

Insert the widget to layout and connect the signals.

addWidget(widget: FieldWidgetProtocol, stretch: int = 0, alignment: dawiq.qt_compat.QtCore.Qt.AlignmentFlag = dawiq.qt_compat.QtCore.Qt.AlignmentFlag)[source]

Add the widget to layout and connect the signals.

removeWidget(widget: FieldWidgetProtocol)[source]

Remove the widget from layout and disconnect the signals.

setRequired(required: bool)[source]

Recursively set required to all subwidgets.