Skip to content

Commit f7ba82e

Browse files
committed
update documentation
1 parent 176d35b commit f7ba82e

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

adafruit_displayio_layout/widgets/annotation.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: MIT
44
"""
55
6-
`Annotation`
6+
`annotation`
77
================================================================================
88
A widget for annotating other widgets or freeform positions.
99
@@ -34,56 +34,66 @@ class Annotation(Widget):
3434
be used freeform by using ``(x,y)`` parameter.
3535
3636
: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.
4241
4342
:param Widget widget: the widget to be annotated, all dimensions are relative to
4443
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
4746
of the widget).
4847
4948
:param str text: text to be displayed in the annotation.
5049
:param Font font: font to be used for the text.
5150
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
5352
(A,B) tuple in relative units of the size of the widget,
5453
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``
5655
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)).
5857
:type anchor_point: Tuple[float, float]
5958
6059
: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).
6362
:type anchored_position: Tuple[int, int]
6463
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
6665
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).
6867
:type position_offset: Tuple[int, int]
6968
7069
: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).
7271
: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).
7473
7574
:param int stroke: the annotation line width (in pixels). [NOT currently implemented]
7675
7776
:param int line_color: the color of the annotation line (default: 0xFFFFFF).
7877
: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``).
8079
8180
: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)).
8382
:type text_offset: Tuple[int, int]
8483
8584
: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*
8797
"""
8898

8999
def __init__(

docs/annotation_example.png

4.86 KB
Loading

docs/annotation_example.png.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
3+
SPDX-License-Identifier: MIT

docs/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@
3333
.. automodule:: adafruit_displayio_layout.widgets.icon_widget
3434
:members:
3535
:member-order: bysource
36+
37+
.. automodule:: adafruit_displayio_layout.widgets.annotation
38+
:members:
39+
:member-order: bysource

0 commit comments

Comments
 (0)