Adafruit_CircuitPython_RGB_Display icon indicating copy to clipboard operation
Adafruit_CircuitPython_RGB_Display copied to clipboard

Code is using deprecated getsize() function

Open aabaker opened this issue 2 years ago • 1 comments

The line https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/7ecfffe3deac982f8698e72da7033b836c07ecd5/examples/rgb_display_minipitftstats.py#L90 plus a few just below it use the deprecated function getsize() which has been removed in the latest release of Pillow. Using getbbox() instead and then using [3] instead of [1] seems like a reasonable workaround

aabaker avatar Dec 27 '23 23:12 aabaker

Updating the "Write four lines of text." part of the code with the following code fixed the issue for me.

    # Write four lines of text.
    y = top
    draw.text((x, y), IP, font=font, fill="#FFFFFF")
    y += font.getbbox(IP)[3]
    draw.text((x, y), CPU, font=font, fill="#FFFF00")
    y += font.getbbox(CPU)[3]
    draw.text((x, y), MemUsage, font=font, fill="#00FF00")
    y += font.getbbox(MemUsage)[3]
    draw.text((x, y), Disk, font=font, fill="#0000FF")
    y += font.getbbox(Disk)[3]
    draw.text((x, y), Temp, font=font, fill="#FF00FF")

thejunglejim avatar Sep 14 '24 15:09 thejunglejim