displayio_annotation
¶
A widget for annotating other widgets or freeform positions.
Author(s): Kevin Matocha
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- class displayio_annotation.Annotation(x=None, y=None, text=None, font=terminalio.FONT, delta_x=- 15, delta_y=- 10, widget=None, anchor_point=(0.0, 0.0), anchored_position=None, position_offset=(0, 0), stroke=3, line_color=16777215, text_color=None, text_offset=(0, - 1), text_under=False)¶
A widget to be used to annotate other widgets with text and lines, but can also be used freeform by using
(x,y)
parameter.- Parameters
x (int) – x-direction pixel position for the end of the annotation line for freeform positioning,
(x,y)
will be ignored if awidget
andanchor_point
and/oranchored_position
are provided.y (int) – y-direction pixel position for the end of the annotation line for freeform positioning.
widget (Widget) – the widget to be annotated, all dimensions are relative to this widget. The annotation line position will be defined by either the
anchor_point
(in relative dimensions of the size of the widget) or theanchored_position
(in raw pixel dimensions relative to the origin of the widget).text (str) – text to be displayed in the annotation.
font (Font) – font to be used for the text.
anchor_point (Tuple[float, float]) – starting point for the annotation line, where
anchor_point
is an (A,B) tuple in relative units of the size of the widget, for example (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right corner of the widget. Ifanchor_point
isNone
, thenanchored_position
is used to set the annotation line starting point, in widget size relative units (default is (0.0, 0.0)).anchored_position (Tuple[int, int]) – pixel position starting point for the annotation line where
anchored_position
is an (x,y) tuple in pixel units relative to the upper left corner of the widget, in pixel units (default is None).position_offset (Tuple[int, int]) – Used to nudge the line position to where you want, this is an (x,y) pixel offset added to the annotation line starting point, either set by
anchor_point
oranchored_position
(in pixel units).delta_x (int) – the pixel x-offset for the second end of the line where the text will reside, in pixel units (default: -15).
delta_y (int) – the pixel y-offset for the second end of the line where the text will reside, in pixel units (default: -10).
stroke (int) – the annotation line width (in pixels). [NOT currently implemented]
line_color (int) – the color of the annotation line (default: 0xFFFFFF).
text_color (int) – the color of the text, if set to
None
color will be set toline_color
(default: same asline_color
).text_offset (Tuple[int, int]) – a (x,y) pixel offset to adjust text position relative to annotation line, in pixel units (default: (0,-1)).
text_under (Boolean) – set
True
for text to be placed below the annotation line (default: False).
Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2 leads to a layer’s pixel being 2x2 pixels when in the group.