You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

qt-theme-manager

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qt-theme-manager

A comprehensive theme management library for PyQt5/PyQt6/PySide6 applications

0.2.4
pipPyPI
Maintainers
1

Qt-Theme-Manager for PyQt5/PyQt6/PySide6

CI/CD Tests PyPI version PyPI - Python Version License: MIT

A comprehensive theme management library for PyQt5/PyQt6/PySide6 applications, providing dynamic theme switching with an advanced theme editor and 16+ built-in themes.

✨ What's New in v0.2.4

🦓 NEW: Zebra Pattern Auto-Generation

  • Real-time Contrast Adjustment: Interactive slider and direct input for contrast ratios (1.15:1 to 1.80:1)
  • WCAG 2.1 Compliant: Scientific color calculations with HSL/HSV color space support
  • 3 Accessibility Levels: Subtle (1.15:1), Moderate (1.30:1), High (1.80:1) contrast options
  • Multi-platform Support: PyQt5/PyQt6/PySide6 cross-framework compatibility
  • Integrated Theme Editor: New zebra tab in theme editor with live preview
  • Standalone Mode: Dedicated zebra pattern editor for focused color work

🎨 Enhanced Theme Features

  • Enhanced CLI Preview Features: Support for --config and --theme options
  • Major Accessibility Improvements: 6% lightness contrast for zebra stripes (WCAG-compliant)
  • Theme Format Conversion: Convert custom themes to Qt-Theme-Manager format
  • Unified Theme Improvements: Accessibility optimization across all 16 themes
  • Entry Points Added: theme-editor, theme-preview commands for easy launching
  • Python 3.9+ Support: Dropped Python 3.8 support, optimized for modern environments

✨ What's New in v0.2.1

  • 🔧 Fixed GUI Startup Issues: Theme editor now launches reliably across all Qt frameworks
  • ⚙️ Enhanced Qt Compatibility: Full support for PyQt5, PyQt6, and PySide6
  • 🚀 Improved Startup Methods: Both module and script execution work perfectly
  • 📦 Better Error Handling: Cleaner error messages and interruption support

Features

  • 🎨 16+ Built-in Themes: Light, Dark, High Contrast, and colorful themes
  • 🦓 NEW: Zebra Pattern Auto-Generation: WCAG-compliant alternating row colors with real-time contrast adjustment
  • Advanced Accessibility: Scientific color calculations for optimal contrast ratios (1.15:1-1.80:1)
  • Enhanced Theme Editor: Professional-grade theme creation tools with integrated zebra pattern generator
  • 🔄 Dynamic Theme Switching: Change themes at runtime without restarting
  • 💾 Persistent Settings: Theme preferences are automatically saved
  • 🖥️ Multi-mode GUI Tools: Integrated editor, standalone zebra editor, and preview applications
  • 📟 Enhanced CLI Support: Theme preview with custom configs and themes
  • 🎯 Easy Integration: Simple API for applying themes to widgets/applications
  • QSS Generation: Automatic stylesheet generation from theme configurations
  • 🔄 Theme Format Conversion: Convert custom themes to Qt-Theme-Manager format

🚀 30-Second Quick Start

Want to try the NEW zebra pattern auto-generation?

# Install and launch integrated theme editor with zebra patterns
pip install qt-theme-manager[pyqt6]
python launch_zebra_theme_editor.py --mode full

# Or try the standalone zebra pattern editor
python launch_zebra_theme_editor.py --mode standalone

# Demo the zebra generation capabilities
python launch_zebra_theme_editor.py --mode demo

Want to try the enhanced theme editor?

# Launch theme editor (New entry points!)
theme-editor

# Alternative launch methods (all work reliably):
python -m theme_manager.qt.theme_editor
python launch_theme_editor.py  # If you cloned the repo

Want to add beautiful themes to your Qt app in just 3 lines of code?

from theme_manager.qt.controller import apply_theme_to_widget

# That's it! Apply current theme to any widget:
apply_theme_to_widget(your_widget)

Want to switch themes dynamically?

from theme_manager.qt.controller import ThemeController

controller = ThemeController()
controller.set_theme("dark")  # or "light", "blue", "cyberpunk", etc.
controller.apply_theme_to_application()

16 beautiful themes ready to use: dark, light, blue, green, cyberpunk, ocean, and more!

Installation

# Basic installation
pip install qt-theme-manager

# Install with your preferred Qt framework (Enhanced compatibility in v0.2.1!)
pip install qt-theme-manager[pyqt6]    # For PyQt6 (recommended)
pip install qt-theme-manager[pyqt5]    # For PyQt5  
pip install qt-theme-manager[pyside6]  # For PySide6

# Install with all Qt frameworks
pip install qt-theme-manager[all]

✨ New in v0.2.1: Enhanced Qt framework compatibility ensures reliable operation across PyQt5, PyQt6, and PySide6.

Option 2: Install from source (for developers)

git clone https://github.com/scottlz0310/Qt-Theme-Manager.git
cd Qt-Theme-Manager

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or: venv\Scripts\activate  # Windows

# Install with your preferred Qt framework
pip install -e .[pyqt6]    # For PyQt6
# pip install -e .[pyqt5]  # For PyQt5
# pip install -e .[pyside6] # For PySide6

Requirements

  • Python 3.9+
  • PyQt5, PyQt6, or PySide6 (for GUI functionality)

Quick Start

Basic Usage

from theme_manager.qt.controller import apply_theme_to_widget
from PyQt5.QtWidgets import QApplication, QMainWindow

app = QApplication([])
window = QMainWindow()

# Apply current theme to widget
apply_theme_to_widget(window)

window.show()
app.exec_()

Using ThemeController

from theme_manager.qt.controller import ThemeController

# Initialize theme controller
controller = ThemeController()

# Get available themes
themes = controller.get_available_themes()
print("Available themes:", list(themes.keys()))

# Switch theme
controller.set_theme("dark")

# Apply to application
controller.apply_theme_to_application()

Command Line Interface

🎨 GUI Tools (Enhanced in v0.2.4!)

After installing via pip, you can use these convenient GUI tools:

# Launch the advanced theme editor
theme-editor

# Launch theme preview window  
theme-preview

# NEW: Launch zebra pattern theme editor (integrated mode)
python launch_zebra_theme_editor.py --mode full

# NEW: Launch standalone zebra pattern editor
python launch_zebra_theme_editor.py --mode standalone

# NEW: Demo zebra pattern generation capabilities
python launch_zebra_theme_editor.py --mode demo

# Enhanced preview with custom configuration and theme (v0.2.3)
theme-preview --config custom_themes.json --theme ocean
theme-preview --config accessibility_themes.json --theme orange
theme-preview -c my_themes.json -t dark

# Use CLI tools
theme-manager --help

⚡ CLI Options (New in v0.2.3!)

The theme-preview command now supports flexible options:

  • --config, -c: Specify custom theme configuration file (JSON format)
  • --theme, -t: Set initial theme to apply on startup
  • --help, -h: Show help message with usage examples

🎯 Usage Examples

# Preview with default themes
theme-preview

# Use custom accessibility-improved themes
theme-preview --config accessibility_themes.json

# Start with specific theme
theme-preview --theme amber

# Combine custom config and theme
theme-preview --config my_improved_themes.json --theme "Orange (Improved)"

Theme Editor Features

  • Color theory-based color selection (complementary, triadic, analogous)
  • Real-time preview of all changes
  • Component-specific settings for detailed customization
  • Accessibility features with contrast ratio checking
  • Import/Export custom themes

Theme Preview Features

  • 16 built-in themes to test instantly
  • Live switching between themes
  • All Qt widgets displayed for comprehensive testing

♿ Accessibility Enhancements (New in v0.2.3!)

Qt-Theme-Manager now provides enhanced accessibility features:

Zebra Stripe Optimization

  • 6% lightness contrast for alternating row colors
  • WCAG-compliant design for better readability
  • Eye-strain reduction for long-term usage
  • Automatic application to QListWidget, QTreeWidget, QTableWidget

Usage Example

# Enable zebra stripes with improved accessibility
list_widget.setAlternatingRowColors(True)
controller.apply_theme_to_widget(list_widget)
# Colors are automatically optimized for accessibility

Available Accessibility-Enhanced Themes

  • Orange (Improved) - Enhanced contrast for orange theme
  • Yellow (Improved) - Improved readability for yellow theme
  • Lime (Improved) - Optimized green-yellow theme
  • Amber (Improved) - Enhanced amber theme with better contrast

Legacy CLI Methods

For advanced users or scripting:

# New entry points (recommended)
theme-manager list
theme-manager set dark
theme-manager export dark dark_theme.qss
theme-manager current

# Legacy methods  
python -m theme_manager.cli.main list
python -m theme_manager.cli.main set dark
python -m theme_manager.cli.main export dark dark_theme.qss
python -m theme_manager.cli.main current
python -m theme_manager.main current

Available Themes

The library includes 16 built-in themes:

Core Themes

  • light - Light mode with bright background
  • dark - Dark mode with low-strain colors
  • high_contrast - High contrast for accessibility

Color Themes

  • blue - Professional blue-based theme
  • green - Natural green-based theme
  • purple - Elegant purple-based theme
  • orange - Warm orange-based theme
  • pink - Playful pink-based theme
  • red - Bold red-based theme
  • teal - Calm teal-based theme
  • yellow - Bright yellow-based theme
  • gray - Simple gray-based theme
  • sepia - Eye-friendly sepia theme
  • cyberpunk - Neon cyberpunk theme
  • forest - Natural forest theme
  • ocean - Deep ocean blue theme

Configuration

Themes are defined in config/theme_settings.json. Each theme includes:

  • Basic Colors: background, text, primary, accent
  • Component Styles: buttons, inputs, panels, toolbars
  • Text Variants: primary, secondary, muted, success, warning, error

Example Theme Configuration

{
  "dark": {
    "name": "dark",
    "display_name": "ダークモード",
    "description": "暗い背景の低負荷テーマ",
    "backgroundColor": "#1a1a1a",
    "textColor": "#eeeeee",
    "primaryColor": "#222831",
    "accentColor": "#00adb5",
    "button": {
      "background": "#4a5568",
      "text": "#ffffff",
      "hover": "#00adb5"
    }
  }
}

Advanced Usage

Custom Theme Configuration

from theme_manager.qt.controller import ThemeController

# Use custom config file
controller = ThemeController("/path/to/custom/config.json")

Theme Preview Window

from theme_manager.qt.preview import show_preview

# Show interactive preview window
preview_window = show_preview()

Manual QSS Generation

from theme_manager.qt.stylesheet import StylesheetGenerator

theme_config = {...}  # Your theme configuration
generator = StylesheetGenerator(theme_config)

# Generate complete stylesheet
qss = generator.generate_qss()

# Generate specific widget styles
button_qss = generator.generate_widget_qss('button')

Project Structure

theme_manager/
├── __init__.py                 # Main package exports
├── config/
│   └── theme_settings.json     # Theme definitions
├── qt/
│   ├── __init__.py
│   ├── loader.py               # JSON configuration loader
│   ├── stylesheet.py           # QSS generation
│   ├── controller.py           # Theme management
│   └── preview.py              # GUI preview window
├── cli/
やえ│   ├── __init__.py
│   └── themectl.py             # CLI interface
└── main.py                     # CLI entry point

Testing

Run the test suite to verify functionality:

python test_theme_manager.py

This will test:

  • Theme loading and configuration
  • Stylesheet generation
  • Theme switching
  • CLI functionality
  • QSS export

API Reference

ThemeController

Main class for theme management.

Methods

  • get_available_themes() - Get all available themes
  • get_current_theme_name() - Get current active theme
  • set_theme(theme_name, save_settings=True) - Switch to specified theme
  • apply_theme_to_widget(widget) - Apply theme to specific widget
  • apply_theme_to_application(app=None) - Apply theme to entire application
  • export_qss(output_path, theme_name=None) - Export QSS to file

ThemeLoader

Handles loading and saving theme configurations.

Methods

  • load_settings() - Load theme configuration from file
  • get_available_themes() - Get available themes dict
  • get_current_theme() - Get current theme name
  • update_current_theme(theme_name) - Update and save current theme

StylesheetGenerator

Generates QSS stylesheets from theme configurations.

Methods

  • generate_qss() - Generate complete QSS stylesheet
  • generate_widget_qss(widget_type) - Generate QSS for specific widget type
  • validate_theme_config(theme_config) - Validate theme configuration

License

[Add your license information here]

Contributing

[Add contribution guidelines here]

Changelog

Version 0.0.1 (Initial Release)

  • Basic theme management functionality
  • 16 built-in themes
  • CLI interface
  • GUI preview window
  • QSS export functionality

Keywords

theme

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts