adding a label example
This commit is contained in:
parent
d74656c372
commit
eec7b341b8
1 changed files with 25 additions and 0 deletions
25
examples/bitmap_font_label_simpletest.py
Normal file
25
examples/bitmap_font_label_simpletest.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"""
|
||||
This example uses addfruit_display_text.label to display text using a custom font
|
||||
loaded by adafruit_bitmap_font
|
||||
"""
|
||||
|
||||
import board
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
from adafruit_display_text import label
|
||||
|
||||
display = board.DISPLAY
|
||||
|
||||
# Set text, font, and color
|
||||
text = "HELLO WORLD"
|
||||
font = bitmap_font.load_font("fonts/Arial-16.bdf")
|
||||
color = 0xFF00FF
|
||||
|
||||
# Create the tet label
|
||||
text_area = label.Label(font, text=text, color=color)
|
||||
|
||||
# Set the location
|
||||
text_area.x = 20
|
||||
text_area.y = 20
|
||||
|
||||
# Show it
|
||||
display.show(text_area)
|
||||
Loading…
Reference in a new issue