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

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

2
position_label_below bool

If True, the position labels will appear below the move buttons. If False, the position labels will appear to the right of the move buttons.

True
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
"""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_layout = QHBoxLayout(wdg)

stages = list(mmc.getLoadedDevicesOfType(DeviceType.XYStage))
stages.extend(mmc.getLoadedDevicesOfType(DeviceType.Stage))
for stage in stages:
    lbl = "Z" if mmc.getDeviceType(stage) == DeviceType.Stage else "XY"
    bx = QGroupBox(f"{lbl} Control")
    bx_layout = QHBoxLayout(bx)
    bx_layout.setContentsMargins(0, 0, 0, 0)
    bx_layout.addWidget(StageWidget(device=stage, position_label_below=True))
    wdg_layout.addWidget(bx)


wdg.show()
app.exec()