Finally, you must call show_custom_badge() to display the badge background and badge lines we set up.

pybadger.show_custom_badge()

Following the set up of badge_background and badge_line, you MUST include this line of code! show_custom_badge() triggers the background and text lines to display. Without it, nothing will display.

If you have no other code in your while True: loop, you should call show_custom_badge() inside the loop. For example, if all you wanted to do was show the badge, you could use the following code:

from adafruit_pybadger import pybadger

pybadger.badge_background(background_color=pybadger.WHITE,
                          rectangle_color=pybadger.PURPLE,
                          rectangle_drop=0.2, rectangle_height=0.6)

pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE,
                    scale=2, padding_above=2)
[...]

while True:
	pybadger.show_custom_badge()

If you have other code in the loop, you can call show_custom_badge() before the loop to display the badge on startup and allow for the code to display different things in the loop.

That's all there is to using creating a custom badge with a color-block background!

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

This page (Show Custom Badge) was last updated on Feb 28, 2020.

Text editor powered by tinymce.