Skip to content

PropertyWidget

PropertyWidget widget

This image generated from example code below.

PropertyWidget #

Bases: QWidget

Widget to display and control a single device property.

Parameters:

Name Type Description Default
device_label str

Device label.

required
prop_name str

Property name.

required
parent QWidget | None

Optional parent widget.

None
mmcore CMMCorePlus | None

Optional core instance. If not provided, uses the global instance.

None
connect_core bool

If True, widget changes update the core and vice versa.

True

inner_widget: QWidget property #

Return the inner value widget (spinbox, slider, combobox, etc).

allowedValues() -> tuple[str, ...] #

Return allowed values if property has constraints.

deviceType() -> DeviceType #

Return the device type.

isPreInit() -> bool #

Return True if the property is pre-initialization.

isReadOnly() -> bool #

Return True if the property is read-only.

propertyType() -> PropertyType #

Return the property type.

refresh() -> None #

Update the value of the widget from mmcore.

(If all goes well this shouldn't be necessary, but if a propertyChanged event is missed, this can be used).

setValue(value: Any) -> None #

Set the widget value.

value() -> Any #

Get the current widget value.

Example#

property_widget.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from pymmcore_plus import CMMCorePlus
from qtpy.QtWidgets import QApplication, QFormLayout, QWidget

from pymmcore_widgets import PropertyWidget

app = QApplication([])

mmc = CMMCorePlus().instance()
mmc.loadSystemConfiguration()

wdg = QWidget()
wdg.setLayout(QFormLayout())

devs_pros = [
    ("Camera", "AllowMultiROI"),
    ("Camera", "Binning"),
    ("Camera", "CCDTemperature"),
]

for dev, prop in devs_pros:
    prop_wdg = PropertyWidget(dev, prop)
    wdg.layout().addRow(f"{dev}-{prop}:", prop_wdg)

wdg.show()

app.exec_()