Skip to content

UI services and widgets

UI orchestration services and reusable widget containers.

📡 Theme signal integration

EzQt_App emits themeChanged whenever the active theme is switched via the settings panel flow (set_app_theme() / refresh_theme()).

Use this signal to refresh custom widgets that keep theme-dependent caches outside standard QSS repaint behavior.

from ezqt_app import EzQt_App

window = EzQt_App().build()

def on_theme_changed() -> None:
    # Recompute theme-dependent resources in custom components.
    ...

window.themeChanged.connect(on_theme_changed)

📦 ThemeService

ThemeService

Service responsible for loading and applying QSS themes.

Theme variables are declared without prefix in theme config files (e.g. main_surface) and referenced in QSS files using the standard CSS custom property notation var(--variable_name). The service resolves each reference to its palette value before applying the stylesheet.

apply_theme staticmethod

apply_theme(window: MainWindowProtocol) -> None

Load all QSS files from the themes directory and apply the merged stylesheet.

All .qss files found under <app_root>/bin/themes/ are loaded in alphabetical order and concatenated before palette variables are resolved. When that directory is absent or empty, the package's own resources/themes/ directory is used as fallback.

Parameters:

Name Type Description Default
window MainWindowProtocol

The application window whose ui.styleSheet will be updated. Must expose window.ui.styleSheet.setStyleSheet.

required

get_available_themes staticmethod

get_available_themes() -> list[tuple[str, str]]

Return available theme options as (display_label, internal_value) pairs.

Reads palette keys from theme.config.yaml and generates one entry per preset × variant combination, e.g. ("Blue Gray - Dark", "blue_gray:dark").

Returns:

Type Description
list[tuple[str, str]]

List of (display_label, internal_value) tuples, one per theme variant.

MenuService

Service responsible for menu item selection state and style refresh.

select_menu staticmethod

select_menu(window: MainWindowProtocol, widget: str) -> None

Set active class on a menu button identified by its object name.

deselect_menu staticmethod

deselect_menu(window: MainWindowProtocol, widget: str) -> None

Set inactive class on all menu buttons except the selected one.

refresh_style staticmethod

refresh_style(widget: QWidget) -> None

Re-apply widget style after dynamic property changes.

📦 PanelService

PanelService

Service responsible for menu and settings panel animations.

toggle_menu_panel staticmethod

toggle_menu_panel(window: MainWindowProtocol, enable: bool) -> None

Animate the left menu panel between shrink and extended widths.

toggle_settings_panel staticmethod

toggle_settings_panel(window: MainWindowProtocol, enable: bool) -> None

Animate the right settings panel and synchronize theme toggle.

📦 WindowService

WindowService

Service responsible for maximize/restore and window state flags.

maximize_restore staticmethod

maximize_restore(window: MainWindowProtocol) -> None

Toggle between maximized and restored window state.

get_status staticmethod

get_status() -> bool

Return the current maximize/restore status.

set_status staticmethod

set_status(status: bool) -> None

Persist the current maximize/restore status.

📦 UiComponentFactory

UiComponentFactory

UiComponentFactory()

Bases: UiComponentFactoryProtocol

Factory that exposes predefined UI component specifications.

Initialize the factory.

initialize

initialize() -> None

Mark the factory as initialized (specs are statically defined).

get_font

get_font(name: str) -> FontSpec | None

Return a predefined font specification by name.

get_size_policy

get_size_policy(name: str) -> SizePolicySpec | None

Return a predefined size policy specification by name.

📦 Core widgets

EzApplication

EzApplication(*args: Any, **kwargs: Any)

Bases: QApplication

Extended main application with theme and UTF-8 encoding support.

This class inherits from QApplication and adds functionality for theme management and UTF-8 encoding.

Initialize the application with UTF-8 and high resolution support.

Parameters

args : Any Positional arguments passed to QApplication. *kwargs : Any Keyword arguments passed to QApplication.

create_for_testing classmethod

create_for_testing(*args: Any, **kwargs: Any) -> EzApplication

Create an EzApplication instance for testing, bypassing singleton checks.

Header

Header(app_name: str = '', description: str = '', parent: QWidget | None = None, *args: Any, **kwargs: Any)

Bases: QFrame

Application header with logo, name and control buttons.

This class provides a customizable header bar with the application logo, its name, description and window control buttons (minimize, maximize, close).

Initialize the application header.

Parameters:

Name Type Description Default
app_name str

Application name (default: "").

''
description str

Application description (default: "").

''
parent QWidget | None

The parent widget (default: None).

None
*args Any

Additional positional arguments.

()
**kwargs Any

Additional keyword arguments.

{}

set_app_name

set_app_name(app_name: str) -> None

Set the application name in the header.

Parameters:

Name Type Description Default
app_name str

The new application name.

required

set_app_description

set_app_description(description: str) -> None

Set the application description in the header.

Parameters:

Name Type Description Default
description str

The new application description.

required

retranslate_ui

retranslate_ui() -> None

Apply current translations to all owned text labels and tooltips.

changeEvent

changeEvent(event: QEvent) -> None

Handle Qt change events, triggering UI retranslation on language change.

Parameters:

Name Type Description Default
event QEvent

The QEvent instance.

required
set_app_logo(logo: str | QPixmap, y_shrink: int = 0, y_offset: int = 0) -> None

Set the application logo in the header.

Parameters:

Name Type Description Default
logo str | QPixmap

The logo to display (file path or QPixmap).

required
y_shrink int

Vertical reduction of the logo (default: 0).

0
y_offset int

Vertical offset of the logo (default: 0).

0

set_settings_panel_open

set_settings_panel_open(is_open: bool) -> None

Update the open dynamic property on the settings button.

The property is used by QSS to apply an accent background when the settings panel is visible. Calling this method forces Qt to re-evaluate the style rules for the button immediately.

Parameters:

Name Type Description Default
is_open bool

True when the settings panel is opening, False when it is closing.

required

update_all_theme_icons

update_all_theme_icons() -> None

Update all button icons according to current theme.

Menu

Menu(parent: QWidget | None = None, shrink_width: int = 60, extended_width: int = 240)

Bases: QFrame

Menu container with expansion/reduction support.

This class provides a menu container with a toggle button to expand or reduce the menu width. The menu contains an upper section for menu items and a lower section for the toggle button.

Initialize the menu container.

Parameters

parent : QWidget, optional The parent widget (default: None). shrink_width : int, optional Width when menu is shrunk (default: 60). extended_width : int, optional Width when menu is extended (default: 240).

retranslate_ui

retranslate_ui() -> None

Apply current translations to all owned text labels and tooltips.

changeEvent

changeEvent(event: QEvent) -> None

Handle Qt change events, triggering UI retranslation on language change.

add_menu

add_menu(name: str, icon: QIcon | str | None = None)

Add a menu item to the container.

update_all_theme_icons

update_all_theme_icons() -> None

Update theme icons for all buttons.

sync_all_menu_states

sync_all_menu_states(extended: bool) -> None

Sync all menu buttons to the given state.

get_menu_state

get_menu_state() -> bool

Get the current menu state.

get_shrink_width

get_shrink_width() -> int

Get the configured shrink width.

get_extended_width

get_extended_width() -> int

Get the configured extended width.

PageContainer

PageContainer(parent: QWidget | None = None)

Bases: QFrame

Page container with stacked widget management.

This class provides a container to manage multiple pages within a central receptacle using a QStackedWidget.

Initialize the page container.

Parameters

parent : QWidget, optional The parent widget (default: None).

add_page

add_page(name: str) -> QWidget

Add a new page to the container.

Parameters

name : str The name of the page to add.

Returns

QWidget The created page widget.

set_current_widget

set_current_widget(widget: QWidget) -> None

Set the current visible page.

Parameters

widget : QWidget The page widget to display.

get_stacked_widget

get_stacked_widget() -> QStackedWidget

Access the internal stacked widget.

Note: Use set_current_widget for standard navigation.

SettingsPanel

SettingsPanel(parent: QWidget | None = None, width: int = 240, load_from_yaml: bool = True)

Bases: QFrame

This class is used to create a settings panel. It contains a top border, a content settings frame and a theme settings container. The settings panel is used to display the settings.

load_settings_from_yaml

load_settings_from_yaml() -> None

Load settings from YAML file.

add_setting_from_config

add_setting_from_config(key: str, config: dict) -> QWidget

Add a setting based on its YAML configuration.

add_toggle_setting

add_toggle_setting(key: str, label: str, default: bool = False, description: str = '', enabled: bool = True)

Add a toggle setting.

add_select_setting

add_select_setting(key: str, label: str, options: list[str], default: str | None = None, description: str = '', enabled: bool = True)

Add a selection setting.

add_slider_setting

add_slider_setting(key: str, label: str, min_val: int, max_val: int, default: int, unit: str = '', description: str = '', enabled: bool = True)

Add a slider setting.

add_text_setting

add_text_setting(key: str, label: str, default: str = '', description: str = '', enabled: bool = True)

Add a text setting.

add_checkbox_setting

add_checkbox_setting(key: str, label: str, default: bool = False, description: str = '', enabled: bool = True)

Add a checkbox setting.

get_setting_value

get_setting_value(key: str) -> Any

Get the value of a setting.

set_setting_value

set_setting_value(key: str, value: Any) -> None

Set the value of a setting.

get_all_settings

get_all_settings() -> dict[str, Any]

Get all settings and their values.

save_all_settings_to_yaml

save_all_settings_to_yaml() -> None

Stage all current setting values.

retranslate_ui

retranslate_ui() -> None

Apply current translations to all owned text labels.

changeEvent

changeEvent(event: QEvent) -> None

Handle Qt change events.

get_width

get_width() -> int

Get panel width.

set_width

set_width(width: int) -> None

Set panel width.

get_theme_selector

get_theme_selector()

Get the theme selector if available.

update_all_theme_icons

update_all_theme_icons() -> None

Update theme icons for all widgets that support it.

add_setting_widget

add_setting_widget(widget: QWidget) -> None

Add a new setting widget to the settings panel.

add_setting_section

add_setting_section(title: str = '') -> QFrame

Add a new settings section with optional title.

scroll_to_top

scroll_to_top() -> None

Scroll to top of settings panel.

scroll_to_bottom

scroll_to_bottom() -> None

Scroll to bottom of settings panel.

scroll_to_widget

scroll_to_widget(widget: QWidget) -> None

Scroll to a specific widget in the settings panel.

📦 Extended widgets

setting_widgets

Setting widget components: toggle, select, slider, text, checkbox.

BaseSettingWidget

BaseSettingWidget(label: str, description: str = '')

Bases: QWidget

Base class for all setting widgets.

set_key

set_key(key: str)

Set the setting key.

retranslate_ui

retranslate_ui()

To be implemented by subclasses.

SettingToggle

SettingToggle(label: str, description: str = '', default: bool = False)

Bases: BaseSettingWidget

Widget for toggle settings (on/off).

retranslate_ui

retranslate_ui()

Update strings after language change.

SettingSelect

SettingSelect(label: str, description: str = '', options: list | None = None, default: str | None = None)

Bases: BaseSettingWidget

Widget for selection settings.

SettingSlider

SettingSlider(label: str, description: str = '', min_val: int = 0, max_val: int = 100, default: int = 50, unit: str = '')

Bases: BaseSettingWidget

Widget for numeric settings with slider.

SettingText

SettingText(label: str, description: str = '', default: str = '')

Bases: BaseSettingWidget

Widget for text settings.

SettingCheckbox

SettingCheckbox(label: str, description: str = '', default: bool = False)

Bases: BaseSettingWidget

Widget for checkbox settings (on/off).