Skip to content

PropertyWidget

PropertyWidget widget

This image generated from example code below.

PropertyWidget #

Bases: QWidget

A widget to display and control a specified mmcore 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. By default, None.

None
mmcore CMMCorePlus | None

Optional pymmcore_plus.CMMCorePlus micromanager core. By default, None. If not specified, the widget will use the active (or create a new) CMMCorePlus.instance.

None
connect_core bool

Whether to connect the widget to the core. If False, the widget will not update the core when the value changes. By default, True.

True

Raises:

Type Description
ValueError

If the device_label is not loaded, or does not have a property prop_name.

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

Return tuple of allowable values if property is categorical.

connectCore(mmcore: CMMCorePlus | None = None) -> None #

Connect to core.

Connect the widget to the core. This is the default state.

deviceType() -> DeviceType #

Return property type.

disconnectCore() -> None #

Disconnect from core.

Disconnect the widget from the core. This will prevent the widget from updating the core when the value changes.

isReadOnly() -> bool #

Return True if property is read only.

propertyType() -> PropertyType #

Return 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 current value of the widget (which should match mmcore).

value() -> Any #

Get value.

Return the current value of the widget (which should match mmcore).

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_()