Web Colors v2.0.0
A friendly, dependency-free color toolkit for Flet that makes your code clearer by using named colors instead of raw hex values. It also ships with the manipulation and accessibility helpers you reach for every day: palette generation, WCAG contrast checks, alpha blending, HSL/HSV conversion, and more.
Features
- Color management — hundreds of named colors, always one attribute away.
- Readable code —
WColors.AMARANTHbeats"#E52B50". - Color math — lighten, darken, saturate, rotate, invert, blend, and mix.
- Palettes — complementary, triadic, tetradic, analogous, gradients, shades, tints.
- Accessibility — WCAG contrast ratio and best-text-color helpers so your UI stays legible on any background.
- Conversions — hex ↔ RGB ↔ HSL ↔ HSV.
- Zero runtime dependencies —
fletis only needed when you're actually building a UI.
Installation
Install from GitHub:
pip install git+https://github.com/osamalzabidi/flet-wcolors.git
Install from PyPi:
pip install flet-wcolors
Basic usage
import flet as ft
from flet_wcolors import WColors
def main(page: ft.Page):
page.title = "Web Colors Example"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.window.width = 800
page.window.height = 600
page.add(
ft.Container(
width=400,
height=400,
bgcolor=WColors.AMARANTH,
alignment=ft.Alignment.CENTER,
border_radius=8,
content=ft.Text(value="AMARANTH"),
)
)
ft.run(main)
Output of above code
Advanced usage
Accessibility
from flet_wcolors import WColors
bg = WColors.INDIGO
# Accurate WCAG contrast ratio (1.0 – 21.0)
print(WColors.contrast_ratio(bg, WColors.WHITE)) # e.g. 8.3
# Automatically pick black or white for best readability
text = WColors.best_text_color(bg) # "#ffffff"
print(bg.is_dark) # True
print(WColors.SNOW.is_light) # True
Manipulation
from flet_wcolors import WColors
base = WColors.CORNFLOWER_BLUE
print(WColors.lighten(base, 0.15)) # lighter
print(WColors.darken(base, 0.15)) # darker
print(WColors.saturate(base, 0.2)) # more vivid
print(WColors.desaturate(base, 0.2)) # muted
print(WColors.rotate(base, 45)) # hue-shifted
print(WColors.grayscale(base)) # monochrome
print(WColors.invert(base)) # RGB-inverted
print(WColors.blend(base, WColors.WHITE, 0.4))
Palettes
from flet_wcolors import WColors
print(WColors.complementary(WColors.RED))
print(WColors.triadic(WColors.RED)) # [red, green, blue-ish]
print(WColors.tetradic(WColors.RED)) # four evenly spaced hues
print(WColors.analogous(WColors.RED, count=5)) # neighbors around red
print(WColors.gradient(WColors.RED, WColors.BLUE, 5))
print(WColors.shades(WColors.INDIGO, 5)) # darker → darker
print(WColors.tints(WColors.INDIGO, 5)) # lighter → lighter
Conversions
from flet_wcolors import WColors
r, g, b = WColors.RED.rgb
h, s, l = WColors.RED.hsl # all in [0.0, 1.0]
h, s, v = WColors.RED.hsv # all in [0.0, 1.0]
# Build a color from HSL/HSV components
hex_from_hsl = WColors.from_hsl(0.5, 1.0, 0.5) # "#00ffff"
hex_from_hsv = WColors.from_hsv(0.5, 1.0, 1.0) # "#00ffff"
# Normalize whatever you have into "#rrggbb"
WColors.normalize("RED") # "#ff0000"
WColors.normalize((255, 0, 0)) # "#ff0000"
WColors.normalize("#f00") # "#ff0000"
Alpha & Flet integration
from flet_wcolors import WColors
# Flet can render "#RRGGBB,opacity"
bg = WColors.CRIMSON.with_alpha(0.8)
bg = WColors.CRIMSON + 0.8 # same thing
# … or an rgba() CSS string
css = WColors.CRIMSON.to_rgba(0.8) # "rgba(220, 20, 60, 0.8)"
Reproducible random
from flet_wcolors import WColors
first = WColors.random(seed=42)
second = WColors.random(seed=42)
assert first == second
Introspection
from flet_wcolors import WColors
print(len(WColors.all())) # every color
print(WColors.names()[:5]) # ['RED', 'CHERRY_RED', ...]
WColors.from_name("crimson") # WColors.CRIMSON
WColors.is_valid("crimson") # True
WColors.is_valid("nope") # False
Contributing
Pull requests and suggestions are welcome! Open an issue first to discuss any major changes.
License
Apache-2.0 — see LICENSE.
Metadata
Release files for flet-wcolors 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flet_wcolors-2.0.0.tar.gz | 31.2 kB | With provenance | Details for flet_wcolors-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flet_wcolors-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for flet_wcolors-2.0.0-py3-none-any.whl |
Total release size: 58.5 kB
Release files / flet_wcolors-2.0.0.tar.gz
| Download URL | flet_wcolors-2.0.0.tar.gz |
|---|---|
| Size | 31.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2883d3fa60fa339efbbdd62adb3bd23f7c65349a3ce1772837862a7cdaa8583d
|
|
BLAKE2b-256 checksum How to use checksums |
f610ec521e646c7cd066e2d96d9c2a58de9d4648d3cda8cb8bc07d15281d957d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / flet_wcolors-2.0.0-py3-none-any.whl
| Download URL | flet_wcolors-2.0.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5e55cbf93f315ebb5caf896d651438c47d46a20c5c754bfad369f9b542ad8b9
|
|
BLAKE2b-256 checksum How to use checksums |
7c880deda2f95fc1faf64b01932731ecc0116e20b0aeb904736728e23c5098e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for flet-wcolors 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for flet_wcolors-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.