pyqt_reactive.theming.palette_manager

QPalette Manager for OpenHCS PyQt6 GUI

Manages QPalette integration with ColorScheme for system-wide theming. Provides utilities for applying color schemes to Qt’s palette system and managing theme switching across the entire application.

Classes

PaletteManager(color_scheme)

Manages QPalette integration with ColorScheme.

ThemeManager([initial_color_scheme])

High-level theme management for the entire application.

class pyqt_reactive.theming.palette_manager.PaletteManager(color_scheme: ColorScheme)[source]

Manages QPalette integration with ColorScheme.

Provides methods to apply color schemes to Qt’s palette system, enabling system-wide theming and consistent color application.

__init__(color_scheme: ColorScheme)[source]

Initialize the palette manager with a color scheme.

Parameters:

color_scheme – ColorScheme instance to use for palette generation

update_color_scheme(color_scheme: ColorScheme)[source]

Update the color scheme used for palette generation.

Parameters:

color_scheme – New ColorScheme instance

create_palette() QPalette[source]

Create a QPalette from the current color scheme.

Returns:

Configured palette with color scheme colors

Return type:

QPalette

apply_palette_to_application(app: QApplication | None = None)[source]

Apply the color scheme palette to the entire application.

Parameters:

app – QApplication instance (uses QApplication.instance() if None)

restore_original_palette(app: QApplication | None = None)[source]

Restore the original application palette.

Parameters:

app – QApplication instance (uses QApplication.instance() if None)

get_palette_info() dict[source]

Get information about the current palette configuration.

Returns:

Dictionary with palette color information

Return type:

dict

class pyqt_reactive.theming.palette_manager.ThemeManager(initial_color_scheme: ColorScheme | None = None)[source]

High-level theme management for the entire application.

Coordinates color scheme, style sheet generation, and palette management to provide seamless theme switching capabilities.

__init__(initial_color_scheme: ColorScheme | None = None)[source]

Initialize the theme manager.

Parameters:

initial_color_scheme – Initial color scheme (defaults to dark theme)

switch_to_dark_theme()[source]

Switch to dark theme variant.

switch_to_light_theme()[source]

Switch to light theme variant.

apply_color_scheme(color_scheme: ColorScheme)[source]

Apply a new color scheme to the entire application.

Parameters:

color_scheme – New ColorScheme to apply

register_theme_change_callback(callback)[source]

Register a callback to be called when theme changes.

Parameters:

callback – Function to call with new color scheme

unregister_theme_change_callback(callback)[source]

Unregister a theme change callback.

Parameters:

callback – Function to remove from callbacks

get_current_style_sheet() str[source]

Get the current complete application style sheet.

Returns:

Complete QStyleSheet for current theme

Return type:

str

load_theme_from_config(config_path: str) bool[source]

Load and apply theme from configuration file.

Parameters:

config_path – Path to JSON configuration file

Returns:

True if successful, False otherwise

Return type:

bool

save_current_theme(config_path: str) bool[source]

Save current theme to configuration file.

Parameters:

config_path – Path to save JSON configuration file

Returns:

True if successful, False otherwise

Return type:

bool