pdwidgets.widgets.label
Text label widget.
- class pdwidgets.widgets.label.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=16, scale=1, inverted=False, font_data=None, font=None)[source]
Bases:
WidgetText display using romfont or an optional proportional font.
- draw(_=None)[source]
Draw the label’s text on the screen, using absolute coordinates. Optionally fills the background first if
bgis set.
- text_width(text=None)[source]
Return the pixel width of
textwithout drawing.Uses this label’s current typeface settings: proportional
fontwhen set, otherwise the romfont attext_height/scale(and optionalfont_data). Defaults to measuringvalue.Newlines are not special-cased (same contract as
pygraphics.Font.text_width/write_width).- Parameters:
text (str | None) – String to measure;
Noneusesself.value.- Returns:
int – Width in pixels.
- property char_width
Rendered character width in pixels.
- property char_height
Rendered character height in pixels.