Colors (or Colours)
You can set colors in guizero using:
- the name of the color -
white - a #rgb hex value -
#ffffff - a list of rgb values -
(255,255,255)
Colors can be used as either starting parameters e.g. :
app = App(bg = "red")
app = App(bg = "#ff0000")
app = App(bg = (255, 0, 0))
or as properties e.g. :
text = Text(app, text = "hi")
text.text_color = "green"
text.text_color = "#00ff00"
text.text_color = (0, 255, 0)
If a color is set using a list of rgb values ((255,255,255)) it will be returned as an #rgb hex value (#ffffff)
Color names
Color names can be given as strings e.g.
whiteblackredgreenblueyellow
A complete list of color names is available at wiki.tcl.tk/37701
rgb hex value
A rgb color value must start with a # and 6 characters following, 2 each for the red, green and blue value in hex. Each value must be 00 - ff e.g.
- white =
#ffffff - black =
#000000 - red =
#ff0000 - green =
#00ff00 - blue =
#0000ff - yellow =
#ffff00
You can mix your own color by changing the red, green and blue values.
There is a RGB calculator application at https://www.w3schools.com/colors/colors_rgb.asp where you can create your own color and get the #rrggbb value.
rgb list
The (red, green, blue) list color, must have 3 elements in the order red, green, blue with values 0 - 255 e.g.
- white = (255, 255, 255)
- black = (0, 0, 0)
- red = (255, 0, 0)
- green = (0, 255, 0)
- blue = (0, 0, 255)
- yellow = (255, 255, 0)