Perhaps the color-block badge background doesn't suit your needs and you'd rather have the background be an image. This is easy with the PyBadger custom badge!
First, you'll need a compatible bitmap image. We've included one below. A couple more are available here. For information on how to create your own compatible bitmaps, check out the Customization section of the Notifcation Icons page in this guide.
Copy the desired bitmap to your CIRCUITPY drive.
Once the bitmap is copied to your CIRCUITPY drive, simply replace the badge_background
line(s) with the following code.
pybadger.image_background("Blinka_CLUE.bmp")
You must provide the name of a compatible bitmap as a string (e.g. in quotation marks: "Blinka.bmp"
).
The rest of the badge set up is the same. Add your lines of text using badge_line()
and then call show_custom_badge()
.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT """Custom image badge example for Adafruit CLUE.""" from adafruit_pybadger import pybadger pybadger.image_background("Blinka_CLUE.bmp") pybadger.badge_line(text="@circuitpython", color=pybadger.SKY, 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.SKY, scale=4, padding_above=4) while True: pybadger.show_custom_badge()
That's all there is to using creating a custom badge with an image background!
Page last edited January 20, 2025
Text editor powered by tinymce.