colour
colour copied to clipboard
Add colour preview method
Colour previews
Allows users to easily preview a colour using the Color.preview()
method.
What changed?
A new preview
method was added to the Color
class, allowing for quick and easy colour previews.
How does it work?
The preview method uses Tkinter, which is included in every Python installation, and should be consistent across operating systems.
The method creates a root window, sets its geometry, sets its title and sets the background colour to whatever colour is stored in this Color
class.
Why?
I was recently browsing old projects of mine, and I stumbled across a list of Color
objects. Wanting to view those colours, I searched for a quick and easy way to preview colours in Python.
After failing miserably, I took it upon myself to implement a preview method for the Color
class.
Also, why would anyone want to implement an essential feature all by themselves?
Examples
>>> import colour
>>>
>>> c = colour.Color("#9F1231")
>>> c.preview() # Preview a single colour
>>>
>>> for i in c.range_to(colour.Color("#000"), 8):
... i.preview(geometry=(200, 100)) # Preview a colour with custom geometry
...