-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Several lines from badger2040/displayio_example.py are not working on latest CircuitPython:
Adafruit CircuitPython 9.2.4 on 2025-01-29; Pimoroni Badger 2040 W with rp2040
>>>
>>> import board
>>> import terminalio
>>> import displayio
>>> import vectorio
>>> from adafruit_display_text import label
>>>
>>> """
... An example of how to show text on the Badger 2040's
... screen using the built-in DisplayIO object.
... """
"\nAn example of how to show text on the Badger 2040's\nscreen using the built-in DisplayIO object.\n"
>>>
>>> display = board.DISPLAY
>>>
>>> # Set text, font, and color
>>> title = "HELLO WORLD"
>>> subtitle = "From CircuitPython"
>>> font = terminalio.FONT
>>> color = 0x000000
>>>
>>> # Set the palette for the background color
>>> palette = displayio.Palette(1)
>>> palette[0] = 0xFFFFFF
>>>
>>> # Add a background rectangle
>>> rectangle = vectorio.Rectangle(pixel_shader=palette, width=display.width + 1, height=display.height, x=0, y=0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'width'
>>>
>>> # Create the title and subtitle labels
>>> title_label = label.Label(font, text=title, color=color, scale=4)
>>> subtitle_label = label.Label(font, text=subtitle, color=color, scale=2)
>>>
>>> # Set the label locations
>>> title_label.x = 20
>>> title_label.y = 45
>>>
>>> subtitle_label.x = 40
>>> subtitle_label.y = 90
>>>
>>> # Create the display group and append objects to it
>>> group = displayio.Group()
>>> group.append(rectangle)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'rectangle' is not defined
>>> group.append(title_label)
>>> group.append(subtitle_label)
>>>
>>> # Show the group and refresh the screen to see the result
>>> display.show(group)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'show'
>>> display.refresh()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'refresh'
Metadata
Metadata
Assignees
Labels
No labels