|
3 | 3 | # SPDX-License-Identifier: MIT
|
4 | 4 | """
|
5 | 5 |
|
6 |
| -`Annotation` |
| 6 | +`annotation` |
7 | 7 | ================================================================================
|
8 | 8 | A widget for annotating other widgets or freeform positions.
|
9 | 9 |
|
@@ -34,56 +34,66 @@ class Annotation(Widget):
|
34 | 34 | be used freeform by using ``(x,y)`` parameter.
|
35 | 35 |
|
36 | 36 | :param int x: x-direction pixel position for the end of the annotation line for
|
37 |
| - freeform positioning, will be ignored if a ``widget`` and ``anchor_point`` and/or |
38 |
| - ``anchored_position`` are provided |
39 |
| - :param int x: x-direction pixel position for the end of the annotation line for |
40 |
| - freeform positioning, will be ignored if a ``widget`` and ``anchor_point`` and/or |
41 |
| - ``anchored_position`` are provided |
| 37 | + freeform positioning, ``(x,y)`` will be ignored if a ``widget`` and ``anchor_point`` and/or |
| 38 | + ``anchored_position`` are provided. |
| 39 | + :param int y: y-direction pixel position for the end of the annotation line for |
| 40 | + freeform positioning. |
42 | 41 |
|
43 | 42 | :param Widget widget: the widget to be annotated, all dimensions are relative to
|
44 | 43 | this widget. The annotation line position will be defined by either
|
45 |
| - the `anchor_point` (in relative dimensions of the size of the widget) |
46 |
| - or the `anchored_position` (in raw pixel dimensions relative to the origin |
| 44 | + the ``anchor_point`` (in relative dimensions of the size of the widget) |
| 45 | + or the ``anchored_position`` (in raw pixel dimensions relative to the origin |
47 | 46 | of the widget).
|
48 | 47 |
|
49 | 48 | :param str text: text to be displayed in the annotation.
|
50 | 49 | :param Font font: font to be used for the text.
|
51 | 50 |
|
52 |
| - :param anchor_point: starting point for the annotation line, where `anchor_point` is an |
| 51 | + :param anchor_point: starting point for the annotation line, where ``anchor_point`` is an |
53 | 52 | (A,B) tuple in relative units of the size of the widget,
|
54 | 53 | for example (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower
|
55 |
| - right corner of the widget. If `anchor_point` is `None`, then `anchored_position` |
| 54 | + right corner of the widget. If ``anchor_point`` is `None`, then ``anchored_position`` |
56 | 55 | is used to set the annotation line starting point, in widget size relative units
|
57 |
| - (default is (0.0, 0.0)) |
| 56 | + (default is (0.0, 0.0)). |
58 | 57 | :type anchor_point: Tuple[float, float]
|
59 | 58 |
|
60 | 59 | :param anchored_position: pixel position starting point for the annotation line
|
61 |
| - where `anchored_position` is an (x,y) tuple in pixel units relative to the |
62 |
| - upper left corner of the widget, in pixel units (default is None) |
| 60 | + where ``anchored_position`` is an (x,y) tuple in pixel units relative to the |
| 61 | + upper left corner of the widget, in pixel units (default is None). |
63 | 62 | :type anchored_position: Tuple[int, int]
|
64 | 63 |
|
65 |
| - :param position_offset: Used to 'nudge' the line position to where you want, this |
| 64 | + :param position_offset: Used to *nudge* the line position to where you want, this |
66 | 65 | is an (x,y) pixel offset added to the annotation line starting
|
67 |
| - point, either set by `anchor_point` or `anchored_position` (in pixel units). |
| 66 | + point, either set by ``anchor_point`` or ``anchored_position`` (in pixel units). |
68 | 67 | :type position_offset: Tuple[int, int]
|
69 | 68 |
|
70 | 69 | :param int delta_x: the pixel x-offset for the second end of the line where the text
|
71 |
| - will reside, in pixel units (default: -15) |
| 70 | + will reside, in pixel units (default: -15). |
72 | 71 | :param int delta_y: the pixel y-offset for the second end of the line where the text
|
73 |
| - will reside, in pixel units (default: -10) |
| 72 | + will reside, in pixel units (default: -10). |
74 | 73 |
|
75 | 74 | :param int stroke: the annotation line width (in pixels). [NOT currently implemented]
|
76 | 75 |
|
77 | 76 | :param int line_color: the color of the annotation line (default: 0xFFFFFF).
|
78 | 77 | :param int text_color: the color of the text, if set to `None` color will be
|
79 |
| - set to `line_color` (default: same as `line_color`). |
| 78 | + set to ``line_color`` (default: same as ``line_color``). |
80 | 79 |
|
81 | 80 | :param text_offset: a (x,y) pixel offset to adjust text position relative
|
82 |
| - to annotation line, in pixel units (default: (0,-1)) |
| 81 | + to annotation line, in pixel units (default: (0,-1)). |
83 | 82 | :type text_offset: Tuple[int, int]
|
84 | 83 |
|
85 | 84 | :param Boolean text_under: set `True` for text to be placed below the
|
86 |
| - annotation line (default: False) |
| 85 | + annotation line (default: False). |
| 86 | +
|
| 87 | + .. figure:: annotation_example.png |
| 88 | + :scale: 125 % |
| 89 | + :align: center |
| 90 | + :alt: Example of the annotation widget. |
| 91 | +
|
| 92 | + Example of the annotation widget showing two widget |
| 93 | + annotations (using ``widget`` and ``anchor_point`` input parameters) and a |
| 94 | + freeform annotation (using ``x`` and ``y`` input parameters). |
| 95 | +
|
| 96 | + File location: *examples/displayio_layout_annotation_simpletest.py* |
87 | 97 | """
|
88 | 98 |
|
89 | 99 | def __init__(
|
|
0 commit comments