Update mini_pitft_stats.py to use getbbox() instead of getsize()

A little update to avoid message "DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead."
This commit is contained in:
vegatripy 2025-01-28 15:31:12 +01:00 committed by GitHub
parent c9f2d95e5a
commit 9e1eaba7c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -107,26 +107,26 @@ while True:
y = top
if not buttonA.value: # just button A pressed
draw.text((x, y), IP, font=font, fill="#FFFF00")
y += font.getsize(IP)[1]
y += font.getbbox(IP)[3]
draw.text((x, y), CPU, font=font, fill="#FFFF00")
y += font.getsize(CPU)[1]
y += font.getbbox(CPU)[3]
draw.text((x, y), MemUsage, font=font, fill="#00FF00")
y += font.getsize(MemUsage)[1]
y += font.getbbox(MemUsage)[3]
draw.text((x, y), Disk, font=font, fill="#0000FF")
y += font.getsize(Disk)[1]
y += font.getbbox(Disk)[3]
draw.text((x, y), Temp, font=font, fill="#FF00FF")
y += font.getsize(Temp)[1]
y += font.getbbox(Temp)[3]
else:
draw.text((x, y), IP, font=font, fill="#FFFF00")
y += font.getsize(IP)[1]
y += font.getbbox(IP)[3]
draw.text((x, y), HOST, font=font, fill="#FFFF00")
y += font.getsize(HOST)[1]
y += font.getbbox(HOST)[3]
draw.text((x, y), "Ads Blocked: {}".format(str(ADSBLOCKED)), font=font, fill="#00FF00")
y += font.getsize(str(ADSBLOCKED))[1]
y += font.getbbox(str(ADSBLOCKED))[3]
draw.text((x, y), "Clients: {}".format(str(CLIENTS)), font=font, fill="#0000FF")
y += font.getsize(str(CLIENTS))[1]
y += font.getbbox(str(CLIENTS))[3]
draw.text((x, y), "DNS Queries: {}".format(str(DNSQUERIES)), font=font, fill="#FF00FF")
y += font.getsize(str(DNSQUERIES))[1]
y += font.getbbox(str(DNSQUERIES))[3]
# Display image.
disp.image(image, rotation)