8.6.2.15. pymodaq_gui.examples.theming_demo module

8.6.2.15.1. PyMoDAQ Theming Demo — Status Color Palette + Material Icon Toolbar

Run this file directly:

python theming_demo.py

8.6.2.15.1.1. Switching theme at runtime

Switching theme (combobox, or the Play button to auto-cycle through every qt_themes theme) calls pymodaq_gui.qt_utils.apply_theme(name), which sets the palette and style, keeps PyMoDAQ’s dark-theme checkbox rule and emits theme_signaller.theme_changed. Then:

  • the toolbar, built once with an ActionManager, re-colors itself. MaterialIcon (pymodaq_gui.resources.material_icons) bakes the palette color into a pixmap at construction (see SVGIcon._init_colors), so each action keeps what its icon is made of and rebuilds it with the current theme colors on theme_changed (ActionManager.refresh_icons() does it on demand). Colors given by name (ThemeColor.GREEN, 'green', StatusPalette.role('running')) follow the new theme; literal colors ('#3f8f7f') are kept, as is any color of an action created with follow_theme=False;

  • the status-color reference table and the live MultistateLED demo (community-proposed six-state convention, see utils/status_palette.py) are plain widgets with colors computed once, so they are rebuilt.

The toolbar also shows two independent, non-animated uses of icon color:

  • a momentary action (Refresh / Save / Stop) tinted from the same six-state StatusPalette convention as the LEDs above it;

  • a checkable action (Pause / Grid / Zoom) whose icon carries two distinct pixmaps, one per QIcon.State (On/Off), from icon_checked_color. Qt swaps between them on its own from QAction.isChecked(); click a toggle button to see it.

class pymodaq_gui.examples.theming_demo.ThemingDemo(parent=None)[source]

Bases: QWidget

Standalone demo: status-color LEDs + a MaterialIcon toolbar, both retheme correctly.

Methods

closeEvent

closeEvent(event)[source]
staticMetaObject = PySide6.QtCore.QMetaObject("ThemingDemo" inherits "QWidget": )
pymodaq_gui.examples.theming_demo.main()[source]