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 (seeSVGIcon._init_colors), so each action keeps what its icon is made of and rebuilds it with the current theme colors ontheme_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 withfollow_theme=False;the status-color reference table and the live
MultistateLEDdemo (community-proposed six-state convention, seeutils/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
StatusPaletteconvention as the LEDs above it;a checkable action (Pause / Grid / Zoom) whose icon carries two distinct pixmaps, one per
QIcon.State(On/Off), fromicon_checked_color. Qt swaps between them on its own fromQAction.isChecked(); click a toggle button to see it.