A pure theme management library for PyQt5/PyQt6/PySide6 applications with automatic Qt framework detection, providing dynamic theme switching and 16+ built-in themes. v1.0.1 - Production Ready!
Qt-Theme-Managerは、純粋なライブラリとして設計されており、テーマ管理の核となる機能に特化しています。この設計思想は、以下の原則に基づいています:
- ライブラリコア: テーマ管理、スタイルシート生成、Qt統合機能
- GUIツール: テーマエディタ、プレビューアプリケーション(別リポジトリ: qt-theme-studio)
- 明確な責任分界: 各コンポーネントが独立した責任を持つ
- シンプルなAPI: 最小限の依存関係で使いやすいインターフェース
- モジュラー設計: 機能ごとに独立したモジュール構造
- 拡張性: カスタムテーマやプラグインの開発が容易
- 独立したリリースサイクル: ライブラリとGUIツールの個別更新
- 軽量な配布: 必要最小限のファイルサイズ
- 後方互換性: 既存APIの安定性保証
- 開発効率の向上: 関心の分離により、各部分の開発・テスト・保守が独立して行える
- コードの再利用性: ライブラリ機能を他のプロジェクトで簡単に利用可能
- 品質の向上: 焦点を絞った開発により、より高品質なコードを実現
- コミュニティの拡大: シンプルな構造により、外部開発者の参加が促進される
qt-theme-manager (ライブラリ)
├── qt_theme_manager/ # コアライブラリパッケージ
│ ├── qt/ # Qt統合モジュール
│ ├── cli/ # コマンドライン機能
│ └── config/ # 設定管理
└── 最小限の依存関係
qt-theme-studio (GUIツール - 別リポジトリ)
├── テーマエディタ
├── プレビューアプリケーション
├── 高度な編集機能
└── GUI固有の依存関係
この分離により、ライブラリユーザーは軽量で高性能なテーマ管理機能を利用でき、GUI機能が必要な場合は別途qt-theme-studioを使用できます。
- 動的テーマ切り替え: 実行時のテーマ変更とスタイル適用
- Qt自動検出: PySide6 → PyQt6 → PyQt5の自動選択
- スタイルシート生成: テーマ設定からQSSの自動生成
- 設定管理: テーマ設定の永続化と管理
- CLI機能: コマンドライン経由でのテーマ操作
- 軽量設計: 最小限の依存関係で高性能
- クロスプラットフォーム: Windows/macOS/Linux対応
- マルチフレームワーク: PyQt5/PyQt6/PySide6サポート
- 後方互換性: 既存APIの安定性保証
- Python 3.9+: モダンなPython環境に最適化
- WCAG準拠: 科学的な色彩計算による最適なコントラスト
- 縞模様最適化: 6%明度コントラストによる読みやすさ向上
- 目の疲労軽減: 長時間使用に配慮した色彩設計
- 🎨 16+ Built-in Themes: Light, Dark, High Contrast, and colorful themes
- 🔄 Dynamic Theme Switching: Change themes at runtime without restarting
- 💾 Persistent Settings: Theme preferences are automatically saved
- 🎯 Easy Integration: Simple API for applying themes to widgets/applications
- ⚡ QSS Generation: Automatic stylesheet generation from theme configurations
- 📟 CLI Support: Command-line theme management
- ♿ Accessibility Features: WCAG-compliant color calculations and contrast optimization
- 🔧 Qt Auto-Detection: Automatic framework detection (PySide6/PyQt6/PyQt5)
- 📦 Lightweight: Minimal dependencies for optimal performance
3行のコードでQt アプリに美しいテーマを追加:
from qt_theme_manager import apply_theme_to_widget
# ウィジェットに現在のテーマを適用
apply_theme_to_widget(your_widget)動的なテーマ切り替え:
from qt_theme_manager import ThemeController
controller = ThemeController()
controller.set_theme("dark") # "light", "blue", "cyberpunk"など
controller.apply_theme_to_application()CLIでのテーマ管理:
# インストール
pip install qt-theme-manager[pyqt6]
# テーマ一覧表示
qt-theme-manager list
# テーマ切り替え
qt-theme-manager set dark16の美しいテーマが利用可能: dark, light, blue, green, cyberpunk, oceanなど
テーマエディタやプレビューアプリケーションは、別リポジトリ(qt-theme-studio)に移行されました。 ライブラリとしての機能に集中することで、より軽量で高性能なテーマ管理を実現しています。
# Basic installation
pip install qt-theme-manager
# Install with your preferred Qt framework
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]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- Python 3.9+
- PyQt5, PyQt6, or PySide6 (for GUI functionality)
from qt_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_()from qt_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()Qt-Theme-Managerは、コマンドライン経由でのテーマ管理をサポートしています:
# 利用可能なテーマ一覧を表示
qt-theme-manager list
# 現在のテーマを表示
qt-theme-manager current
# テーマを設定
qt-theme-manager set dark
# テーマをQSSファイルにエクスポート
qt-theme-manager export dark dark_theme.qss
# ヘルプを表示
qt-theme-manager --helpテーマエディタやプレビューアプリケーションなどのGUIツールは、qt-theme-studioリポジトリに移行されました:
- テーマエディタ: 高度なテーマ作成・編集機能
- プレビューアプリケーション: リアルタイムテーマプレビュー
- Zebraパターンエディタ: アクセシビリティ対応の縞模様生成
これらのツールを使用する場合は、qt-theme-studioリポジトリをご利用ください。
ライブラリには以下のアクセシビリティ機能が組み込まれています:
# 縞模様の自動最適化
list_widget.setAlternatingRowColors(True)
controller.apply_theme_to_widget(list_widget)
# WCAG準拠の色彩が自動適用されます高度なユーザーやスクリプト用:
# 推奨方法
qt-theme-manager list
qt-theme-manager set dark
qt-theme-manager export dark dark_theme.qss
qt-theme-manager current
# レガシーメソッド
python -m qt_theme_manager.cli.main list
python -m qt_theme_manager.cli.main set dark
python -m qt_theme_manager.main currentThe library includes 16 built-in themes:
- light - Light mode with bright background
- dark - Dark mode with low-strain colors
- high_contrast - High contrast for accessibility
- 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
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
{
"dark": {
"name": "dark",
"display_name": "ダークモード",
"description": "暗い背景の低負荷テーマ",
"backgroundColor": "#1a1a1a",
"textColor": "#eeeeee",
"primaryColor": "#222831",
"accentColor": "#00adb5",
"button": {
"background": "#4a5568",
"text": "#ffffff",
"hover": "#00adb5"
}
}
}from qt_theme_manager.qt.controller import ThemeController
# Use custom config file
controller = ThemeController("/path/to/custom/config.json")from qt_theme_manager.qt.preview import show_preview
# Show interactive preview window
preview_window = show_preview()from qt_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')qt_theme_manager/ # ライブラリコアパッケージ
├── __init__.py # パブリックAPI
├── main.py # CLIエントリーポイント
├── config/
│ └── theme_settings.json # テーマ定義
├── qt/ # Qt統合モジュール
│ ├── __init__.py
│ ├── detection.py # Qt自動検出
│ ├── loader.py # 設定ファイル読み込み
│ ├── stylesheet.py # QSS生成
│ ├── advanced_stylesheet.py # 高度なスタイル機能
│ └── controller.py # テーマ管理
└── cli/ # CLI機能
├── __init__.py
└── themectl.py # CLIインターフェース
以下のGUIツールはqt-theme-studioリポジトリに移行されました:
- テーマエディタ
- プレビューアプリケーション
- Zebraパターンエディタ
- 各種起動スクリプト
Run the test suite to verify functionality:
python test_qt_theme_manager.pyThis will test:
- Theme loading and configuration
- Stylesheet generation
- Theme switching
- CLI functionality
- QSS export
Main class for theme management.
get_available_themes()- Get all available themesget_current_theme_name()- Get current active themeset_theme(theme_name, save_settings=True)- Switch to specified themeapply_theme_to_widget(widget)- Apply theme to specific widgetapply_theme_to_application(app=None)- Apply theme to entire applicationexport_qss(output_path, theme_name=None)- Export QSS to file
Handles loading and saving theme configurations.
load_settings()- Load theme configuration from fileget_available_themes()- Get available themes dictget_current_theme()- Get current theme nameupdate_current_theme(theme_name)- Update and save current theme
Generates QSS stylesheets from theme configurations.
generate_qss()- Generate complete QSS stylesheetgenerate_widget_qss(widget_type)- Generate QSS for specific widget typevalidate_theme_config(theme_config)- Validate theme configuration
[Add your license information here]
[Add contribution guidelines here]
- Basic theme management functionality
- 16 built-in themes
- CLI interface
- GUI preview window
- QSS export functionality