polyfoammesh.gui.theme

Theme manager: applies the design system to a running QApplication.

Three modes:
  • “light”: force light QSS

  • “dark”: force dark QSS

  • “system”: follow OS preference (recommended default)

Usage:

from PySide6.QtWidgets import QApplication from polyfoammesh.gui.theme import apply_theme, set_theme_mode app = QApplication([]) set_theme_mode(“system”) # or “light” / “dark” apply_theme(app)

# later, in a settings dialog: set_theme_mode(“dark”) apply_theme(app)

The QSS strings are embedded in this module (not loaded from disk) so the bundled EXE has no external file dependencies.

Functions

apply_theme([app])

Apply the current theme to app.

current_mode()

Return the currently resolved mode ('light' or 'dark').

current_request()

Return the user's requested mode ('light', 'dark', or 'system').

set_theme_mode(mode)

Convenience: set the requested mode without applying it yet.

Classes

ThemeManager([parent])

Singleton-style theme manager.

class polyfoammesh.gui.theme.ThemeManager(parent=None)[source]

Bases: QObject

Singleton-style theme manager. Tracks current mode and broadcasts changes.

Parameters:

parent (QObject | None)

themeChanged
classmethod instance()[source]
Return type:

ThemeManager

property requested_mode: str
property resolved_mode: str
request(mode)[source]

Set the user’s preferred mode (‘light’, ‘dark’, or ‘system’).

Return type:

None

Parameters:

mode (str)

toggle()[source]

Flip between light and dark; returns the new resolved mode.

Return type:

str

staticMetaObject = PySide6.QtCore.QMetaObject("ThemeManager" inherits "QObject": Methods:   #4 type=Signal, signature=themeChanged(QString), parameters=QString )
polyfoammesh.gui.theme.apply_theme(app=None)[source]

Apply the current theme to app. Returns the resolved mode.

Idempotent: safe to call multiple times. Listens to system theme changes when the requested mode is ‘system’.

Return type:

str

Parameters:

app (QApplication | None)

polyfoammesh.gui.theme.set_theme_mode(mode)[source]

Convenience: set the requested mode without applying it yet.

Return type:

None

Parameters:

mode (str)

polyfoammesh.gui.theme.current_mode()[source]

Return the currently resolved mode (‘light’ or ‘dark’).

Return type:

str

polyfoammesh.gui.theme.current_request()[source]

Return the user’s requested mode (‘light’, ‘dark’, or ‘system’).

Return type:

str