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!
Page last edited March 08, 2024
Text editor powered by tinymce.