control.gui_dict:guiObject

Enum object for GUI elements identification.

Usage

Source

control.gui_dict:guiObject

This enum makes it easier to write readable code and identify GUI elements by their name instead of only by a number.

Attributes

Name Description
button
checkbox
combobox
doublespinbox
hline
labeltext
lineedit
progressbar
spinbox
togglebutton

button

button=0


checkbox

checkbox=2


combobox

combobox=4


doublespinbox

doublespinbox=7


hline

hline=9


labeltext

labeltext=8


lineedit

lineedit=1


progressbar

progressbar=3


spinbox

spinbox=6


togglebutton

togglebutton=5

Methods

Name Description
getWidget() Return the widget of the correct type.

getWidget()

Return the widget of the correct type.

Usage

Source

getWidget(
    label,
    wType,
    init=None,
    *,
    modify=None,
)

Parameters

label: str

Label of the widget; used as fallback button text if no init value is given.

wType: int or guiObject or str

Widget type. Either a guiObject (e.g. guiObject.button) or one of: 0 QPushButton, 1 QLineEdit, 2 QCheckBox, 3 QProgressBar, 4 QComboBox, 5 QPushButton (checkable=True), 6 QSpinBox, 7 QDoubleSpinBox, 8 QLabel (value indicator), 9 QFrame (horizontal separator line), or a str for a QLabel with that text.

init: (tuple, object) = None
Initialization values (button label, valid ranges, combobox entries).

Returns

QWidget or None
Widget of requested type or None.

Examples

Generate a toggle button which changes its label upon being set:

>>> getWidget("Property", guiObject.togglebutton,
...           init=("Slow", "Fast"))

Generate a QComboBox with prefilled options:

>>> getWidget("Property", guiObject.combobox,
...           init=("opt 1", "opt 2"))

Generate a SpinBox (similar for DoubleSpinBox):

>>> getWidget("Property", guiObject.spinbox, init=(0, 200))

Generate a PushBotton with text “Set”:

>>> getWidget("Property", guiObject.button, init="Set")

Generate a label with text “Example”:

>>> getWidget("Property", "Example")