Skip to content

StageWidget

StageWidget widget

This image generated from example code below.

StageWidget #

Bases: QWidget

A Widget to control a XY and/or a Z stage.

Parameters:

Name Type Description Default
device str

Stage device.

required
levels int | None

Number of "arrow" buttons per widget per direction, by default, 2.

2
step float

Starting step size to use for the spinbox in the middle, by default, 10.

10
parent QWidget | None

Optional parent widget.

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

setStep(step: float) -> None #

Set the step size.

step() -> float #

Return the current step size.

Example#

stage_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
27
28
29
30
31
32
33
34
35
36
37
"""Example usage of the StageWidget class.

In this example all the devices of type 'Stage' and 'XYStage' that are loaded
in micromanager are displayed with a 'StageWidget'.
"""

from pymmcore_plus import CMMCorePlus, DeviceType
from qtpy.QtWidgets import QApplication, QGroupBox, QHBoxLayout, QWidget

from pymmcore_widgets import StageWidget

app = QApplication([])

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

wdg = QWidget()
wdg.setLayout(QHBoxLayout())

stage_dev_list = list(mmc.getLoadedDevicesOfType(DeviceType.XYStage))
stage_dev_list.extend(iter(mmc.getLoadedDevicesOfType(DeviceType.Stage)))

for stage_dev in stage_dev_list:
    if mmc.getDeviceType(stage_dev) is DeviceType.XYStage:
        bx = QGroupBox("XY Control")
        bx.setLayout(QHBoxLayout())
        bx.layout().addWidget(StageWidget(device=stage_dev))
        wdg.layout().addWidget(bx)
    if mmc.getDeviceType(stage_dev) is DeviceType.Stage:
        bx = QGroupBox("Z Control")
        bx.setLayout(QHBoxLayout())
        bx.layout().addWidget(StageWidget(device=stage_dev))
        wdg.layout().addWidget(bx)

wdg.show()

app.exec_()