Next, we added the lines of text.
pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=2) pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5, padding_above=3) pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2) pybadger.badge_line(text="she/her", color=pybadger.BLINKA_PINK, scale=4, padding_above=4)
There are six aspects of each line of text you can customise:
-
text: The text to display. Expects a string (text surrounded by quotation marks, e.g.
"Blinka"
). -
color: The color of the text. Expects a tuple (e.g.
(r, g, b)
), or apybadger.COLOR
. Check out the PyBadger Colors page for a list of available colors. If you set the textcolor
to the same color as the part of the badge background it is displayed over, your text will not show up on the display. -
scale: The scale of the text. Expects a whole number 1 or higher. Defaults to
1
. Each increment multiplies the height of the text by the scale value, e.g. a scale of 3 means the text will be 3x higher than a scale of 1. -
font: The font used to display the text. Expects a string (e.g. the name of the font in quotation marks:
"Arial-16.bdf"
). Defaults to the built interminalio.FONT
. Custom fonts require additional files - check out this guide for more information. -
padding_above: The amount of space to include before the line of text. Expects a whole number. Defaults to
0
. For example, settingpadding_above=1
includes an amount of space before the line equal to the height of the current font at scale 1, and settingpadding_above=2
includes an amount of space before the line equal to twice the height of the current font at scale 1, etc. -
left_justify: Set to
True
to left justify the text. Defaults toFalse
. Text is centered by default.
Use scale
to increase the size of the text. Use padding_above
to space out your lines of text by increasing or decreasing the space above each line of text. Try changing the values to see how it affects the displayed text.
When substituting your own text, you may find it doesn't fit with the current values. It can take some experimenting with different values to get your text sized and placed exactly where you want it. The possibilities are endless!
Page last edited March 08, 2024
Text editor powered by tinymce.