Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valer100/winaccent
A simple and lightweight Python module for getting Windows' accent color or a shade of it. Works on both Windows 10 and 11 and doesn't require additional dependencies.
https://github.com/valer100/winaccent
accent accent-color color color-scheme colors fluent fluent-design gui python user-interface win32 winaccent windows windows-10 windows-11 windows10 windows11 winui winui-controls winui3
Last synced: 2 months ago
JSON representation
A simple and lightweight Python module for getting Windows' accent color or a shade of it. Works on both Windows 10 and 11 and doesn't require additional dependencies.
- Host: GitHub
- URL: https://github.com/valer100/winaccent
- Owner: Valer100
- License: mit
- Created: 2024-08-16T10:50:44.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-11T13:06:30.000Z (2 months ago)
- Last Synced: 2024-10-11T14:02:57.326Z (2 months ago)
- Topics: accent, accent-color, color, color-scheme, colors, fluent, fluent-design, gui, python, user-interface, win32, winaccent, windows, windows-10, windows-11, windows10, windows11, winui, winui-controls, winui3
- Language: Python
- Homepage: https://pypi.org/project/winaccent/
- Size: 45 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# winaccent
[![PyPI](https://img.shields.io/pypi/v/winaccent)](https://pypi.org/project/winaccent/)
[![Python](https://img.shields.io/pypi/pyversions/winaccent?color=yellow)]()
[![Downloads](https://img.shields.io/pepy/dt/winaccent)](https://pypi.org/project/winaccent/)
[![Stars](https://img.shields.io/github/stars/Valer100/winaccent?style=flat)]()
[![Contributors](https://img.shields.io/github/contributors/Valer100/winaccent)]()
[![License](https://img.shields.io/github/license/Valer100/winaccent)](https://github.com/Valer100/winaccent/blob/main/LICENSE)A simple and lightweight Python module for getting Windows' accent color or a shade of it. Works on both Windows 10 and 11 and doesn't require additional dependencies.
## 📦 Installation
Run this command in your terminal:```
pip install winaccent
```To update the module, run this command:
```
pip install --upgrade winaccent
```## 📜 Documentation
> [!IMPORTANT]
> This is a Windows-only module. Trying to import this module on a OS other than Windows or a Windows version older than 10 will raise a `winaccent.UnsupportedPlatformException` exception. When using this module in cross-platform applications, you should only import and use winaccent on Windows systems to avoid errors. Here's an example:```python
import sysif sys.platform == "win32":
# The program is running on Windowsimport winaccent
print(winaccent.accent_light_mode)
```---
### Get a specific accent color
> [!NOTE]
> The color values and previews shown here are for Windows 11's default accent color (blue). If you have a different accent color, you'll get the color values based on your accent color.For simplicity, you can get a specific accent color from one of the following variables:
| Variable | Color | Preview |
|----------|:-------:|:-------:|
| accent_dark_mode | #4CC2FF | |
| accent_normal | #0078D4 | |
| accent_light_mode | #0067C0 | |If you need a different shade, you can get it from one of these variables:
| Variable | Color | Preview |
|----------|:-------:|:-------:|
| accent_light_3 | #99EBFF | |
| accent_light_2 | #4CC2FF | |
| accent_light_1 | #0091F8 | |
| accent_normal | #0078D4 | |
| accent_dark_1 | #0067C0 | |
| accent_dark_2 | #003E92 | |
| accent_dark_3 | #001A68 | |You can get the accent color used in lockscreen, UAC (Windows 10) and other elements using `accent_menu` variable (usually it's the same color as `accent_normal`, but can be modified in the registry).
> [!TIP]
> `accent_dark_mode` is the same thing as `accent_light` which is the same thing as `accent_light_2`.
>
> Also, `accent_light_mode` is the same thing as `accent_dark` which is the same thing as `accent_dark_1`.Example:
```python
import winaccentprint(winaccent.accent_light_mode) # Prints the light mode accent color
```You may want to take a look at Microsoft's accent color guidelines. You can do that [here](https://learn.microsoft.com/en-us/windows/apps/design/style/color#accent-color-palette).
---
### Get active/inactive titlebar color or window border color
> [!WARNING]
> The colors provided by these variables are the colors used by Windows to colorize the titlebar and the window borders when the "Show accent color on title bars and window borders" option is enabled in Settings.
>
>
>
> Also, the `titlebar_active` and `window_border` variables don't always return the same color. The user can change the color of the titlebar or window borders from the registry.
>You can get the active titlebar color from `titlebar_active` variable and the inactive titlebar color from `titlebar_inactive`. The window border color can be obtained from `window_border` variable.
You can also check if colored titlebars are enabled using `is_titlebar_colored` boolean.
> [!NOTE]
> `titlebar_inactive` will return `None` if the inactive titlebar color isn't set (this is usually done via registry).---
### Update accent color values
The accent colors can be updated manually using the ```update_accent_colors()``` function. This function will retrieve the values again.
---
### Accent color change listener
This module allows you to add a listener that will call a specific function when the accent color, active/inactive titlebar color or window border color changes. Here's how you can add it:
```python
import winaccent, threading# Replace `callback` with the function that you want to be called
thread = threading.Thread(target = lambda: winaccent.on_accent_changed_listener(callback), daemon = True)
thread.start()
```> [!NOTE]
> If you added the listener, there's no need to call `update_accent_colors()` because it will be called automatically every time the accent color or the active/inactive titlebar color changes.Here's a demo:
https://github.com/user-attachments/assets/5a1f334f-4d04-40a2-816d-f8df6fc523ad
## 💻 Demo
To see a demo, run the following command in your terminal (winaccent must be installed):```python
python -m winaccent
```This command has an optional `--mode` argument. It can take the following values:
| Value | Info |
|:------|:-----|
| gui | Shows a GUI demo. The GUI demo responds to accent color changes. |
| console | Shows a console demo. The console demo **does not** respond to accent color changes. |
| auto | If tkinter is installed and works correctly, a GUI demo will be shown. If that's not the case, a console demo will be shown. |Example usage:
```
python -m winaccent --mode gui
```The command will run with `--mode` set to `auto` by default.
Here's a GUI demo with 6 different accent colors:
| **Blue** | **Dark green** | **Red** |
|:-------:|:---------:|:------:|
|![Blue](https://github.com/Valer100/winaccent/blob/main/assets/demo/demo_blue.png?raw=true) | ![Dark green](https://github.com/Valer100/winaccent/blob/main/assets/demo/demo_green.png?raw=true) | ![Red](https://github.com/Valer100/winaccent/blob/main/assets/demo/demo_red.png?raw=true) |
| **Gold** | **Iris pastel** | **Camouflage desert** |
|![Gold](https://github.com/Valer100/winaccent/blob/main/assets/demo/demo_orange.png?raw=true) | ![Iris pastel](https://github.com/Valer100/winaccent/blob/main/assets/demo/demo_purple.png?raw=true) | ![Camouflage desert](https://github.com/Valer100/winaccent/blob/main/assets/demo/demo_tan.png?raw=true) |A console demo looks like this (for default blue accent color):
```
Accent palette
==============accent_light_3: #99EBFF
accent_light_2: #4CC2FF
accent_light_1: #0091F8
accent_normal: #0078D4
accent_dark_1: #0067C0
accent_dark_2: #003E92
accent_dark_3: #001A68Windows options
===============is_titlebar_colored: False
titlebar_active: #0078D4
titlebar_inactive: None
window_border: #0078D4
```## 🤩 Feedback
If you found a bug or want to make a suggestion, open a new issue. If you're ready to add a new feature or fix a bug, pull requests are welcome.If you find this module useful, please consider starring this repository.
## 📋 To do
- [x] ~~Add an accent color change listener~~
- [x] ~~Add color shades~~
- [x] ~~Allow to get active/inactive titlebar color~~
- [x] ~~Allow to get window border color~~
- [ ] Add support for Windows 8.x