sugar4.graphics.xocolor
This class represents all of the colors that the XO can take on. Each pair of colors represents the fill color and the stroke color.
Modern implementation with improved color handling and CSS support.
Attributes
Classes
Defines color for XO |
Module Contents
- sugar4.graphics.xocolor.colors = [['#B20008', '#FF2B34'], ['#FF2B34', '#B20008'], ['#E6000A', '#FF2B34'], ['#FF2B34', '#E6000A'],...[source]
- class sugar4.graphics.xocolor.XoColor(color_string=None)[source]
Defines color for XO
This class represents a pair of colors (stroke and fill) that can be used throughout Sugar activities. Colors can be parsed from strings, loaded from user settings, or chosen randomly.
- Parameters:
color_string (str, optional) – Color specification in one of these formats: - “stroke_hex,fill_hex” (e.g., “#FF0000,#00FF00”) - “white” for white theme - “insensitive” for disabled/grayed theme - None to use user’s color from settings or random if not available
Examples
>>> #from string >>> color = XoColor("#FF0000,#00FF00") >>> print(color.get_stroke_color()) # "#FF0000" >>> print(color.get_fill_color()) # "#00FF00"
>>> # create user's color (or random if not set) >>> color = XoColor()
>>> # themed colors >>> white_color = XoColor("white") >>> disabled_color = XoColor("insensitive")
- classmethod from_string(color_string)[source]
Create XoColor from string representation.
- Parameters:
color_string (str) – Color string to parse
- Returns:
New XoColor instance
- Return type:
- Raises:
ValueError – If color_string cannot be parsed