TKinter
July 10, 2023 |
permanent
Summary #
GUI framework for
TKinter #
At the moment you are making a new Label every 10 seconds and covering up (not deleting) the older ones. You need to make the Label once, and update the Label, not create a new one every time.
from tkinter import *
from PIL import ImageTk, Image
root= Tk()
plant_stat_panel = Label(root)
plant_stat_panel.grid(row = 5,column = 0, columnspan=2, sticky = W )
def img_updater():
plant_stat_img = ImageTk.PhotoImage(Image.open("/home/pi/wateringsys/html/temp.png"))#/home/pi/html/
plant_stat_panel.config(image = plant_stat_img)
plant_stat_panel.image = plant_stat_img
root.after(10000, img_updater)
img_updater()
root.mainloop()
As soon as you make overwrite the old image, the python garbage collector will automatically free the memory. In python, you should not need to worry about memory allocation.