Skip to main content

Dynamic SVG icon theming tool for PyQt6

Project description

pyqt6-icon-theme

English | 繁體中文

PyQt6 Dynamic Icon Theme Toolkit — Supports automatic light/dark theme switching, hover color effects, and PNG/JPG original color rendering.

Demo

Features

  • SVG Dynamic Recoloring — Automatically strips original fill/stroke and applies any custom color
  • Theme Awareness — Automatically switches between black (light theme) and white (dark theme) when no custom color is set
  • Hover Effect — Switches icon color on mouse enter/leave
  • PNG / JPG Support — Renders raster images at any size while preserving original colors
  • Caching — Icons are cached by (name, color, size, keep_original) to avoid redundant rendering

Installation

pip install pyqt6-icon-theme

Usage

Import the library:

from pyqt6_icon_theme import IconManager, IconButton

Set the icon directory (supports .svg, .png, .jpg, .jpeg); the path name is customizable:

IconManager.set_icon_dir("icons")

IconButton

  • 1st parameter: icon file name — extension is optional
  • 2nd parameter: icon size in pixels
  • 3rd parameter: icon color in normal state — if None, the color is automatically detected from the window background (black on light, white on dark)
  • 4th parameter: icon color on hover — if None, no color change on hover
  • 5th parameter: preserve the SVG's original colors — if True, normal_color and hover_color are ignored; defaults to False
IconButton(name, size=16, normal_color=None, hover_color=None, keep_original=False)

Examples

# Auto color based on theme (light = black, dark = white)
btn = IconButton("user.svg", size=30)

# Custom color + hover effect
btn = IconButton("add.svg", size=36,
                 normal_color="#49ADF0",
                 hover_color="#F08884")

# Preserve SVG original colors (unaffected by theme)
btn = IconButton("edit.svg", size=40, keep_original=True)

# PNG/JPG — always displays original colors
btn = IconButton("delete.png", size=40)

Full Example

See the example folder.

Parameter Behavior Reference

Scenario normal_color hover_color keep_original Result
SVG, no color specified None None False Follows theme (black/white)
SVG, custom color "#49ADF0" "#F08884" False Custom color + hover
SVG, original colors True SVG rendered as-is
PNG / JPG ignored ignored ignored Always original colors

Icon Directory Structure

your_project/
├── icons/
│   ├── user.svg
│   ├── add.svg
│   ├── edit.svg
│   └── delete.png
└── main.py

All .svg, .png, .jpg, .jpeg files in the directory are loaded automatically.

License

MIT © JW5123

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt6_icon_theme-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqt6_icon_theme-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pyqt6_icon_theme-0.1.1.tar.gz.

File metadata

  • Download URL: pyqt6_icon_theme-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.3 Windows/11

File hashes

Hashes for pyqt6_icon_theme-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e3381e3e5ec5c2e0e7a9af4a2aa75ecfe6e12d86364251120c419b2dde37fcd2
MD5 61862ee93fac3c2862a80c949442a869
BLAKE2b-256 051cb9191adfd0caaba0a5cb0f96ffa944832a2a6e096ab6f5335761350f562a

See more details on using hashes here.

File details

Details for the file pyqt6_icon_theme-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyqt6_icon_theme-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.3 Windows/11

File hashes

Hashes for pyqt6_icon_theme-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11f7bcf709f6ee3047793c0a6114d2642d8b2fb795f778bb1f225e44fcd6fc68
MD5 fea012607f800add837753085cf1b91a
BLAKE2b-256 0309d829f8a5e59578861b7f4eb336cc9022c9afa21367503515336f2deb0e08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page