Skip to content

examples

examples

Example implementations demonstrating fxgui module usage.

This module provides a comprehensive showcase application demonstrating the fxgui framework's capabilities, including:

  • Full Application Flow: Splash screen -> Main window with widgets
  • Theme Awareness: Complete guide to making widgets theme-aware
  • Custom Delegates: Thumbnail and color label delegates
  • Various Widgets: Collapsible sections, validators, log output, etc.
Theme Awareness Guide

fxgui provides a complete theme system with automatic updates when the user switches themes. There are several ways to make your code theme-aware:

  1. Icons - Use set_icon() for automatic icon color updates: >>> from fxgui.fxicons import set_icon >>> set_icon(button, "check") # Updates on theme change

  2. FXThemeAware Mixin - For custom widget classes (recommended): >>> class MyWidget(fxstyle.FXThemeAware, QWidget): ... def _on_theme_changed(self, _theme_name: str = None): ... # Called on init and theme changes ... self.setStyleSheet(f"background: {self.theme.surface};")

  3. Custom Colors - Define palettes for dark/light themes: >>> COLORS = { ... "dark": {"red": QColor("#4a2020")}, ... "light": {"red": QColor("#ffcccc")}, ... } >>> def update_colors(_theme_name: str = None): ... palette = COLORS["light" if fxstyle.is_light_theme() else "dark"] ... item.setBackground(0, palette["red"]) >>> fxstyle.theme_manager.theme_changed.connect(update_colors)

  4. Delegate Backgrounds - Update item data on theme change: >>> def update_item_colors(_theme_name: str = None): ... theme = fxstyle.FXThemeColors(fxstyle.get_theme_colors()) ... for item in items: ... item.setBackground(0, QColor(theme.surface_sunken)) ... tree.viewport().update() >>> fxstyle.theme_manager.theme_changed.connect(update_item_colors)

Note

Most widgets have their own example() function in their module. Run individual widget examples with: DEVELOPER_MODE=1 python -m fxgui.fxwidgets._

For example: DEVELOPER_MODE=1 python -m fxgui.fxwidgets._accordion DEVELOPER_MODE=1 python -m fxgui.fxwidgets._delegates

Examples:

Run this module directly to see the full showcase application:

>>> python -m fxgui.examples

Functions:

Name Description
main

Main showcase application demonstrating fxgui capabilities.

Functions

main

main()

Main showcase application demonstrating fxgui capabilities.

This function creates a comprehensive example application with: - Splash screen with loading progress - Main window with tabbed interface - Theme awareness demonstrations - Custom delegate examples - Various widget showcases

The application demonstrates best practices for: - Making icons theme-aware with set_icon() - Updating widget colors on theme change - Creating theme-aware delegate backgrounds