import sys sys.path.append("./lib") import displayio import terminalio # Change this to True to use an I2C display configured below # or False to use PyGameDisplay USE_I2C = False if not USE_I2C: from adafruit_blinka import board from blinka_displayio_pygamedisplay import PyGameDisplay # The key here is "auto_refresh=False". Failing to do so will create a new thread # for the rendering, and macOS (or the Python implementation for it) can only be # performed on the main (UI) thread. display = PyGameDisplay(width=320, height=240, auto_refresh=False) else: from adafruit_displayio_sh1107 import SH1107 import board i2c = board.I2C() display_bus = displayio.I2CDisplay(i2c, device_address=0x3C) display = SH1107(display_bus, width=128, height=128) # This is a trial of the switch_round_horizontal # for use on the PyPortal # #from adafruit_display_text import label from adafruit_display_text import bitmap_label as label # Make the display context splash = displayio.Group(max_size=10) display.show(splash) WIDTH = display.width HEIGHT = display.height # Draw a black background bg_bitmap = displayio.Bitmap(WIDTH, HEIGHT , 1) bg_palette = displayio.Palette(1) bg_palette[0] = 0x000000 splash.append(displayio.TileGrid(bg_bitmap, pixel_shader=bg_palette)) test_label1 = label.Label(terminalio.FONT, text="Scale", scale=1, color=0xFFFFFF, x=8, y=8) print("Test1 : before append to splash") print(f" Scale {test_label1.scale}") splash.append(test_label1) print("Test1 : after append to splash") print(f" Scale {test_label1.scale}") print("test_label1.bounding_box: {}".format(test_label1.bounding_box)) print() test_label2 = label.Label(terminalio.FONT, text="Scale", scale=2, color=0xFFFFFF, x=8, y=38) print("Test2 : before append to splash") print(f" Scale {test_label2.scale}") splash.append(test_label2) print("Test2 : after append to splash") print(f" Scale {test_label2.scale}") print("test_label2.bounding_box: {}".format(test_label2.bounding_box)) print() test_label3 = label.Label(terminalio.FONT, text="Scale", scale=3, color=0xFFFFFF, x=8, y=88) print("Test3 : before append to splash") print(f" Scale {test_label3.scale}") splash.append(test_label3) print("Test3 : after append to splash") print(f" Scale {test_label3.scale}") print("test_label3.bounding_box: {}".format(test_label3.bounding_box)) print() test_label4 = label.Label(terminalio.FONT, text="Scale", scale=8, color=0xFFFFFF, anchor_point=(1.0, 1.0), anchored_position=(WIDTH-8, HEIGHT-8)) print("Test4 : before append to splash") print(f" Scale {test_label4.scale}") splash.append(test_label4) print("Test : after append to splash") print(f" Scale {test_label4.scale}") print("test_label4.bounding_box: {}".format(test_label4.bounding_box)) if hasattr(display, "running"): while display.running: display.refresh()