wijjit.styling.theme.ThemeManager
- class wijjit.styling.theme.ThemeManager[source]
Manages theme registration and switching.
Provides a global registry of themes and handles theme switching at runtime. Applications typically use a single ThemeManager instance.
- Variables:
Examples
Create manager with built-in themes:
>>> manager = ThemeManager() >>> manager.get_theme().name 'default'
Switch themes:
>>> manager.set_theme('dark') >>> manager.get_theme().name 'dark'
Register custom theme:
>>> custom = Theme('custom', {'button': Style(bold=True)}) >>> manager.register_theme(custom) >>> manager.set_theme('custom')
Methods
__init__()Get the currently active theme.
List all registered theme names.
register_theme(theme)Register a theme.
set_theme(theme_name)Set the active theme by name.
- register_theme(theme)[source]
Register a theme.
- Parameters:
theme (
Theme) – Theme to register- Return type:
None
Notes
Overwrites any existing theme with the same name.
Examples
>>> manager = ThemeManager() >>> custom = Theme('custom', {}) >>> manager.register_theme(custom) >>> 'custom' in manager.themes True
- set_theme(theme_name)[source]
Set the active theme by name.
- Parameters:
theme_name (
str) – Name of theme to activate- Raises:
KeyError – If theme name is not registered
- Return type:
None
Examples
>>> manager = ThemeManager() >>> manager.set_theme('dark') >>> manager.get_theme().name 'dark'