label
pdwidgets.widgets.label
Text label widget.
Label(parent, x=0, y=0, w=None, h=None, align=None, align_to=None, fg=None, bg=None, visible=True, value=None, padding=None, text_height=TEXT_SIZE.LARGE, scale=1, inverted=False, font_data=None, font=None)
Bases: Widget
Text display using romfont or an optional proportional font.
Initialize a Label widget to display text.
By default the built-in 8-pixel-wide romfont is used. Passing font
(a proportional bitmap font module from the write_font_converter
pipeline, e.g. chango_32) renders the text with the optional
add_ons/tft_write renderer instead — see the module docstring note
on that dependency. Proportional text is opaque, so a solid bg is
used (the parent's bg when none is given).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Widget
|
The parent widget or screen that contains this label. |
required |
x
|
int
|
The x-coordinate of the label. |
0
|
y
|
int
|
The y-coordinate of the label. |
0
|
w
|
int
|
The width of the label. |
None
|
h
|
int
|
The height of the label. |
None
|
align
|
int
|
The alignment of the label. |
None
|
align_to
|
Widget
|
The widget to align to. |
None
|
fg
|
int
|
The color of the text. |
None
|
bg
|
int
|
The background color of the label. |
None
|
visible
|
bool
|
The visibility of the label. |
True
|
value
|
str
|
The text content of the label. |
None
|
padding
|
tuple
|
The padding on each side of the label. |
None
|
text_height
|
int
|
The height of the romfont text (default TEXT_SIZE.LARGE). |
LARGE
|
scale
|
int
|
The scale of the romfont text (default is 1). |
1
|
inverted
|
bool
|
Invert the romfont text (default is False). |
False
|
font_data
|
str
|
Alternate romfont file/memoryview for the text. |
None
|
font
|
module
|
Proportional bitmap font module ( |
None
|
char_height
property
Rendered character height in pixels.
char_width
property
Rendered character width in pixels.
draw(_=None)
Draw the label's text on the screen, using absolute coordinates.
Optionally fills the background first if bg is set.