3.1.1.2. cairotft.widgets package

widgets.

3.1.1.2.1. Submodules

3.1.1.2.2. cairotft.widgets.base module

base widget class.

class cairotft.widgets.base.BaseAnimatedWidget(display_object, pos_x, pos_y, width, height, interval_time=None)[source]

Bases: cairotft.widgets.base.BaseWidget

Base class for all Animated widgets.

see BaseWidget for All BaseWidget variables

Variables:interval_time (float) – (float) interval between two frames (in seconds)

TODO: add transition support in BaseAnimatedWidget

Initialisation of the base animated widget.

Parameters:
  • display_object (cairotft.tfy.TftDisplay) – the Display class instanciation.
  • pos_x (int) – x coordinates to display the widget
  • pos_y (int) – y coordinates to display the widget
  • width (int) – the width of the widget
  • height (int) – the height of the widget
  • interval_time (float) –

    interval between two frames (in seconds) the widget will first:

    try to use the fps parameter to calculates a display interval or: use the given interval_time or: fix an interval time of 1second
draw(ctx)[source]

draw the widget.

implement this method in your subclasses

show(ctx)[source]

show the icon.

start(ctx)[source]

Start showing the widget.

stop()[source]

stop showing the widget.

class cairotft.widgets.base.BaseWidget(display_object, pos_x, pos_y, width, height)[source]

Bases: builtins.object

Base class for all widgets.

Variables:
  • display_object – (cairotft.tft.TftDisplay) The display object the widget will display itself.
  • pos_x – (int) x coordinates to display the widget
  • pos_y – (int) y coordinates to display the widget
  • width – (int) the width of the widget
  • height – (int) the height of the widget

Initialisation of the base widget.

Parameters:
  • display_object (cairotft.tfy.TftDisplay) – the Display class instanciation.
  • pos_x (int) – x coordinates to display the widget
  • pos_y (int) – y coordinates to display the widget
  • width (int) – the width of the widget
  • height (int) – the height of the widget
draw(ctx)[source]

draw the widget.

implement this method in your subclasses

show(ctx)[source]

show the icon.

start(ctx)[source]

Start showing the widget.

stop()[source]

stop showing the widget.

3.1.1.2.4. cairotft.widgets.marquee module

Text Marquee widget.

class cairotft.widgets.marquee.Marquee(display_object, text, font_face, font_size, text_color, pos_x, pos_y, width, height, background_color=(1, 1, 1, 1), step=1, interval_time=0.05, transition=<bound method type.ease_in of <class 'cairotft.transitions.LinearTransition'>>, smooth=False)[source]

Bases: builtins.object

A text marquee widget.

Initialisation of the Marquee.

Parameters:
  • display_object (cairotft.tft.TftDisplay) – the Display class instanciation.
  • text (str) – the text to display.
  • font_face (cairocffi.ToyFontFace) – the font face used for the text
  • text_color (tuple) – a tuple of 4 float representing the rgba value of the text color.
  • font_size (int) – the size of the font.
  • pos_x (int) – x coordinates of the text box (top left corner)
  • pos_y (int) – y coordinates of the text box (top left corner)
  • width (int) – the width of the text box
  • height (int) – the height of the text box
  • background_color (tuple) – a tuple of 4 float representing the rgba value of the background color to repaint the icon.
  • step (int) – number of unit we skip at each frame. (X chars if smooth is False, X pixels if smooth is True)
  • interval_time (float) – the time in s between two frames
TODO: instead of repainting with a color, save the background or paint
in order: from bottom to top.
_shrink_text(ctx)[source]

based on the font size, calculate the width of the text.

And eventually shrink the name if too long.

_smooth_draw_text()[source]

draw the text in the smooth text buffer.

This is not display, only drawed in the smooth buffer.

_smooth_init_buffer(ctx)[source]

Initialise the buffer used in smooth text.

change_background(background_color)[source]

Change the background color.

Parameters:background_color (tuple) – a tuple of 4 float representing the rgba value of the background color to repaint the icon.
change_color(color)[source]

Change the text color.

Parameters:color (tuple) – a tuple of 4 float representing the rgba value of the text color.
color_changed()[source]

Return True is either text_color or background_color has changed.

(since last paint)

show(ctx, no_loop=False)[source]

Show the text.

start(ctx)[source]

Start showing the marquee.

stop()[source]

stop showing the marquee.