Skip to content

Color-O-Matic reference

Bases: Widget

animated = animate class-attribute instance-attribute

Whether to animate the gradient. This is a boolean value. If True, the gradient will animate.

animation_fps = fps class-attribute instance-attribute

The Frames per second for the animation. This is a float so that you can set it to values such as 0.5 if you desire. The default is 'auto', which will set the FPS to 12 for 'gradient', 12 for 'smooth_strobe', and 1 for 'fast_strobe'.

animation_type = animation_type class-attribute instance-attribute

The type of animation to use for the gradient. This is a string literal type that can be 'gradient', 'smooth_strobe', or 'fast_strobe'. The default is 'gradient'. - 'gradient' will animate the current gradient it in the direction you specify (using the horizontal and reverse settings). - 'smooth_strobe' will create a gradient and animate through the colors. - 'fast_strobe' will hard switch to the next color in the list. It does not make a gradient, and gradient_quality will be ignored.

color_list = colors class-attribute instance-attribute

A list of colors to use for the gradient. This is a list of strings that can be parsed by a Textual Color object. The list can be any number of colors you want. It also supports passing in Textual CSS variables ($primary, $secondary, $accent, etc). When using CSS variables, they will update automatically to match the theme whenever the user of your app changes the theme.

file_dict property

Get the file dictionary from the art loader. This is a dictionary with the directory name as the key and a list of Path objects as the value. The Path objects point to .txt files in that directory.

gradient_quality = gradient_quality class-attribute instance-attribute

The quality of the gradient. This means how many colors the gradient has in it. This is either 'auto' or an integer between 3 and 100. The higher the number, the smoother the gradient will be. By default, in auto mode, this will be calculated depending on the current animation type. - In gradient mode, if vertical, it will be calculated based on the height of the widget. If horizontal, it will be calculated based on the width of the widget. - In smooth_strobe mode, it will be set to (number of colors * 10). - In fast_strobe mode, this setting is ignored.

horizontal = horizontal class-attribute instance-attribute

Whether the gradient should be horizontal or vertical. This is a boolean value. If True, the gradient will be horizontal. If False, the gradient will be vertical. Note that this will have no effect if the animation mode is 'smooth_strobe' or 'fast_strobe' because they do not use a direction.

list_input = reactive(None, always_update=True) class-attribute instance-attribute

The content to render in the Coloromatic. This is the same as text_input but it will take a list of strings instead of a single string. list_input is None by default. If used it will override text_input.

pattern = pattern class-attribute instance-attribute

Choose a built-in pattern from the list of available patterns. If this is set, there is no need to set the text_input or list_input directly.

repeat = repeat class-attribute instance-attribute

Setting this to true will make the content in the Coloromatic repeat to fill the entire space of the Coloromatic. This can be used to make tiling effects. It is also set to True automatically if a pattern is set.

reverse = reverse class-attribute instance-attribute

Whether the animation should run in reverse. This is a boolean value. If True, the animation will run in reverse. If False, the animation will run normally. If horizontal is False, this will switch between up and down. If horizontal is True, this will switch between left and right.
Note that this will have no effect if the animation mode is 'smooth_strobe' or 'fast_strobe' because they do not use a direction.

text_input = content class-attribute instance-attribute

The content to render in the Coloromatic. This is a string that can be any text you want. It can be a single line or multiple lines.

Updated

Bases: Message

Message sent when the Coloromatic is updated.

animated = widget.animated instance-attribute

Whether the Coloromatic is animated. This is a boolean value.

color_mode = widget._color_mode instance-attribute

The color mode that was set. This is a string literal type that can be 'color', 'gradient', or 'none'.

widget = widget instance-attribute

The Coloromatic that was updated.

__init__(content='', *, repeat=False, pattern=None, colors=[], animate=False, animation_type='gradient', gradient_quality='auto', horizontal=False, reverse=False, fps='auto', name=None, id=None, classes=None)

Yar

Parameters:

Name Type Description Default
content str

The content to render in the Coloromatic. It can be a single line or multiple lines.

''
repeat bool

Setting this to true will make the content in the Coloromatic repeat to fill the entire space of the Coloromatic. This can be used to make tiling effects. It is also set to True automatically if a pattern is set.

False
pattern PATTERNS | None

Choose a built-in pattern from the list of available patterns. If this is set, there is no need to set the text_input or list_input directly.

None
colors list[str]

List of colors to use for the gradient. This is a list of strings that can be parsed by a Textual Color object that allows passing in any number of colors you want. It also supports passing in Textual CSS variables ($primary, $secondary, $accent, etc). If using CSS variables, they will update automatically to match the theme whenever the theme is changed.

[]
animate bool

Whether to animate the gradient.

False
animation_type ANIMATION_TYPE

Can be 'gradient', 'smooth_strobe', or 'fast_strobe'. The default is 'gradient'. - 'gradient' will animate the current gradient it in the direction you specify (using the horizontal and reverse settings). - 'smooth_strobe' will create a gradient and animate through the colors. - 'fast_strobe' will hard switch to the next color in the list. It does not make a gradient, and gradient_quality will be ignored.

'gradient'
gradient_quality int | str

The quality of the gradient. This means how many colors the gradient has in it. This is either 'auto' or an integer between 3 and 100. The higher the number, the smoother the gradient will be. By default, in auto mode, this will be calculated depending on the current animation type. - In gradient mode, if vertical, it will be calculated based on the height of the widget. If horizontal, it will be calculated based on the width of the widget. - In smooth_strobe mode, it will be set to (number of colors * 10). - In fast_strobe mode, this setting is ignored.

'auto'
horizontal bool

Whether the gradient should be horizontal or vertical. Note that this will have no effect if the animation mode is 'smooth_strobe' or 'fast_strobe' because they do not use a direction.

False
reverse bool

Whether the animation should run in reverse. If horizontal is False, this will switch between up and down. If horizontal is True, this will switch between left and right. Note that this will have no effect if the animation mode is 'smooth_strobe' or 'fast_strobe' because they do not use a direction. It also does not have an effect on the order of the colors (To change the color order, insert the color list in a different order)

False
fps float | str

The Frames per second for the animation. This is a float so that you can set it to values such as 0.5 if you desire. The default is 'auto', which will set the FPS to 12 for 'gradient', 12 for 'smooth_strobe', and 1 for 'fast_strobe'.

'auto'
name str | None

Name of widget.

None
id str | None

ID of Widget.

None
classes str | None

Space separated list of class names.

None

add_directory(directory)

Add a new directory to the art loader. After using this method the file_dict will be updated to include the new directory.

Parameters:

Name Type Description Default
directory Path

The directory to add.

required

set_animation_type(animation_type)

Set the animation type of the PyFiglet widget.

This method, unlike setting the reactive property, allows passing in a string instead of a string literal type. This is useful for passing in a variable.

Parameters:

Name Type Description Default
animation_type str

The animation type to set. Can be 'gradient', 'smooth_strobe', or 'fast_strobe'.

required

set_color_list(colors)

A list of colors to use for the gradient. This is a list of strings that can be parsed by a Textual Color object. The list can be any number of colors you want. It also supports passing in Textual CSS variables ($primary, $secondary, $accent, etc).

Because the color_list variable is reactive, it is required to use the mutate_reactive method to set it. This method will do that for you.

set_pattern(pattern)

Choose a pattern from a list of built-in options.

Note that this method takes a string instead of a string literal type. This means it can take in variables as input, but it will not provide auto-complete for the available patterns. To get auto-complete, set the Coloromatic.pattern reactive variable directly.

toggle_animated()

Toggle the animated state of the PyFiglet widget. The widget will update with the new animated state automatically.