Color

class widgets.Color(py_color)

A Color object represents a color to be displayed on screen.

Example:

import widgets as wd

# RGB
black = wd.Color.rgb(0, 0, 0, 1)

# White
white = wd.Color.white(1, 1)

# Dynamic
background = wd.Color.dynamic(light=white, dark=black)
alpha() → float

Returns the alpha value of the color.

Return type:

float

blue() → float

Returns the blue value of the color.

Return type:

float

classmethod dynamic(light: 'widgets.Color', dark: 'widgets.Color') → 'widgets.Color'

Initializes and returns a color that dynamically changes in dark or light mode.

Parameters:
  • light – Color object to be displayed in light mode.

  • dark – Color object to be displayed in dark mode.

Return type:

Color

green() → float

Returns the green value of the color.

Return type:

float

red() → float

Returns the red value of the color.

Return type:

float

classmethod rgb(red: float, green: float, blue: float, alpha: float = 1.0) → 'widgets.Color'

Initializes a color from RGB values.

All values should be located between 0 and 1, not between 0 and 255.

Parameters:
  • red – The red value.

  • green – The geen value.

  • blue – The blue value.

  • alpha – The opacity value.

Return type:

Color

classmethod white(white: float, alpha: float) → 'widgets.Color'

Initializes and returns a color from white value.

All values should be located between 0 and 1, not between 0 and 255.

Parameters:
  • white – The grayscale value.

  • alpha – The opacity value.

Return type:

Color