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 a pybadger.COLOR. Check out the PyBadger Colors page for a list of available colors. If you set the text color 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 in terminalio.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, setting padding_above=1 includes an amount of space before the line equal to the height of the current font at scale 1, and setting padding_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 to False. 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!

This guide was first published on Mar 04, 2020. It was last updated on Mar 04, 2020.

This page (Badge Lines) was last updated on Apr 20, 2021.

Text editor powered by tinymce.