Skip to content

pymmcore_gui

A Micro-Manager GUI based on pymmcore-widgets and pymmcore-plus.

Submodules

Name Description
actions Actions: the commands behind pymmcore-gui's menus, toolbars and dock widgets.
widgets Widgets that pymmcore-gui adds to those in pymmcore-widgets.

Classes

Name Description
ActionInfo Information for creating a QCoreAction.
CoreAction Actions that act on the global CMMCore instance.
MicroManagerGUI Micro-Manager minimal GUI.
WidgetAction Widget Actions toggle/create singleton widgets.

Functions

Name Description
create_mmgui Initialize the pymmcore-gui application and Main Window.

Classes

MicroManagerGUI

MicroManagerGUI(*, mmcore: CMMCorePlus | None = None)

Bases: QMainWindow

Micro-Manager minimal GUI.

TOOLBARS

TOOLBARS: Mapping[str, ToolDictValue] = {
    Toolbar.CAMERA_ACTIONS: [CoreAction.SNAP, CoreAction.TOGGLE_LIVE],
    Toolbar.OPTICAL_CONFIGS: OCToolBar,
    Toolbar.WIDGETS: [
        WidgetAction.CONSOLE,
        WidgetAction.PROP_BROWSER,
        WidgetAction.MDA_WIDGET,
        WidgetAction.STAGE_CONTROL,
        WidgetAction.CAMERA_ROI,
    ],
}

MENUS

MENUS: Mapping[str, MenuDictValue] = {
    Menu.PYMM_GUI: [WidgetAction.ABOUT],
    Menu.WINDOW: _create_window_menu,
    Menu.DEVICE: [
        WidgetAction.PROP_BROWSER,
        WidgetAction.CONFIG_WIZARD,
        None,
        CoreAction.LOAD_CONFIG,
        CoreAction.LOAD_DEMO,
        CoreAction.SAVE_CONFIG,
        None,
        WidgetAction.INSTALL_DEVICES,
    ],
    Menu.HELP: [],
}

nm property

nm: NotificationManager

A callable that can be used to show a message in the status bar.

mmcore property

mmcore: CMMCorePlus

get_action

get_action(key: str, create: bool = True) -> QAction

Create a QAction from this key.

get_widget

get_widget(key: Literal[ABOUT], create: bool = ...) -> AboutWidget
get_widget(key: Literal[CAMERA_ROI], create: bool = ...) -> CameraRoiWidget
get_widget(
    key: Literal[CONFIG_GROUPS], create: bool = ...
) -> GroupPresetTableWidget
get_widget(key: Literal[CONFIG_WIZARD], create: bool = ...) -> ConfigWizard
get_widget(key: Literal[CONSOLE], create: bool = ...) -> MMConsole
get_widget(key: Literal[EXCEPTION_LOG], create: bool = ...) -> ExceptionLog
get_widget(key: Literal[INSTALL_DEVICES], create: bool = ...) -> InstallWidget
get_widget(key: Literal[MDA_WIDGET], create: bool = ...) -> MDAWidget
get_widget(
    key: Literal[PIXEL_CONFIG], create: bool = ...
) -> PixelConfigurationWidget
get_widget(key: Literal[PROP_BROWSER], create: bool = ...) -> PropertyBrowser
get_widget(
    key: Literal[STAGE_CONTROL], create: bool = ...
) -> StagesControlWidget
get_widget(key: str, create: bool = ...) -> QWidget
get_widget(key: str, create: bool = True) -> QWidget

Get (or create) widget for key ensuring that it is linked to its QAction.

If the widget has been "closed" (hidden), it will be re-shown.

Note that all widgets created this way are singletons, so calling this method multiple times will return the same widget instance.

Parameters:

Name Type Description Default
key WidgetAction

The widget to get.

required
create bool

Whether to create the widget if it doesn't exist yet, by default True.

True

Raises:

Type Description
KeyError

If the widget doesn't exist and create is False.

get_dock_widget

get_dock_widget(key: str) -> CDockWidget

Get the QDockWidget for key.

Note, you can also get the QDockWidget by calling get_widget(key), and then calling widget.parent(). The parent will either be an instance of QDockWidget (if it's actually a docked widget), or MicroManagerGUI, if it's not docked. You should use isisinstance in this case to check.

Parameters:

Name Type Description Default
key WidgetAction

The key for the inner widget owned by the requested QDockWidget.

required

Raises:

Type Description
KeyError

If the widget doesn't exist.

closeEvent

closeEvent(a0: QCloseEvent) -> None

restore_state

restore_state(*, show: bool = False) -> None

Restore the state of the window from settings (or load default state).

show is added as a convenience here because it may be a common use case to restore the state in a single shot timer and (only) then show the window. This avoids the window flashing on the screen before it is properly positioned.

ActionInfo

Bases: BaseModel

Information for creating a QCoreAction.

key

key: str

A unique key to identify the action.

text

text: str

How the action should be displayed in the GUI.

auto_repeat

auto_repeat: bool = False

checkable

checkable: bool = False

checked

checked: bool = False

enabled

enabled: bool = True

icon

icon: str | None | QIconType = None

icon_text

icon_text: str | None = None

icon_visible_in_menu

icon_visible_in_menu: bool | None = None

menu_role

menu_role: MenuRole | None = None

priority

priority: Priority | None = None

shortcut

shortcut: str | None | QKeySequenceType = None

shortcut_context

shortcut_context: ShortcutContext | None = None

shortcut_visible_in_context_menu

shortcut_visible_in_context_menu: bool | None = None

status_top

status_top: str | None = None

tooltip

tooltip: str | None = None

visible

visible: bool = True

whats_this

whats_this: str | None = None

on_triggered

on_triggered: ActionTriggeredFunc | None = None

on_created

on_created: CoreActionFunc | None = None

model_post_init

model_post_init(__context: Any) -> None

to_qaction

to_qaction(mmc: CMMCorePlus, parent: QObject | None = None) -> QCoreAction

Create a QCoreAction from this info.

for_key classmethod

for_key(key: str) -> Self

Get the ActionInfo for a given key.

widget_actions classmethod

widget_actions() -> dict[str, WidgetActionInfo]

Return all widget actions.

CoreAction

Bases: ActionKey

Actions that act on the global CMMCore instance.

TOGGLE_LIVE

TOGGLE_LIVE = 'pymmcore_gui.toggle_live'

LOAD_DEMO

LOAD_DEMO = 'pymmcore_gui.load_demo_config'

LOAD_CONFIG

LOAD_CONFIG = 'pymmcore_gui.load_config'

SAVE_CONFIG

SAVE_CONFIG = 'pymmcore_gui.save_config'

WidgetAction

Bases: ActionKey

Widget Actions toggle/create singleton widgets.

PROP_BROWSER

PROP_BROWSER = 'pymmcore_gui.property_browser'

PIXEL_CONFIG

PIXEL_CONFIG = 'pymmcore_gui.pixel_config_widget'

INSTALL_DEVICES

INSTALL_DEVICES = 'pymmcore_gui.install_devices_widget'

CONFIG_GROUPS

CONFIG_GROUPS = 'pymmcore_gui.config_groups_widget'

CAMERA_ROI

CAMERA_ROI = 'pymmcore_gui.camera_roi_widget'

EXCEPTION_LOG

EXCEPTION_LOG = 'pymmcore_gui.exception_log'

STAGE_CONTROL

STAGE_CONTROL = 'pymmcore_gui.stage_control_widget'

STAGE_EXPLORER

STAGE_EXPLORER = 'pymmcore_gui.stage_explorer_widget'

CONFIG_WIZARD

CONFIG_WIZARD = 'pymmcore_gui.hardware_config_wizard'

Functions

create_mmgui

create_mmgui(
    *,
    mm_config: Path | str | None | Literal[False] = None,
    mmcore: CMMCorePlus | None = None,
    install_sys_excepthook: bool = True,
    install_sentry: bool = True,
    exec_app: bool = True,
) -> MicroManagerGUI

Initialize the pymmcore-gui application and Main Window.

This is the primary way to start pymmcore-gui. (It is also called by __main__.main() when running from the command line.)

Parameters:

Name Type Description Default
mm_config str | None | False

The path to the Micro-Manager configuration file to load. - If False, no configuration will be loaded. - If a non-empty string, that configuration will be loaded. - If None (or the empty string), auto-deciding logic will be used based on the stored user settings (based on the settings values for Settings.last_config and Settings.auto_load_last_config).

None
mmcore CMMCorePlus | None

The CMMCorePlus instance to use. If None (default), the global CMMCorePlus.instance() will be used if it exists, or a new (global) instance will be created (which you may access later with CMMCorePlus.instance()). Note: you may wish to also pass mm_config = False to prevent loading a system configuration, if you have already loaded one in your instance.

None
install_sys_excepthook bool

If True (the default), installs a custom excepthook that does not raise sys.exit(). This is necessary to prevent the application from closing when an unhandled exception is raised in the main thread.

True
install_sentry bool

If True (the default), the user will be given an option to send error reports to the developers, unless they have previously opted in/out. If False, no prompt will be shown, and no error reports will be sent.

True
exec_app bool

If True (the default), the QApplication event loop will be started. If False, the event loop will not be started, and the caller is responsible for starting it with QApplication.instance().exec().

True