I'm using Tkinter to display images.
Is there a way to completely delete these images from the screen and memory? The way we are deleting at the moment deletes the image but not it's footprint in the ram.
Thanks.
I'm using Tkinter to display images.
Is there a way to completely delete these images from the screen and memory? The way we are deleting at the moment deletes the image but not it's footprint in the ram.
Thanks.
Thanks for the link, I'm reading it now. The solution with the images in the end was to simply have both and 'lift' one above the other when needed. This seems (I hope) to not create e memory leak as the same items are constantly reused:
from tkinter import *
#by David Beck www.dwbeck.com
green_circle = 'Green_Circle.png'
red_circle = 'Red_Circle.png'
def create_image():
if var.get() == 1:
red_button.lift(green_button)
if var.get() == 0:
green_button.lift(red_button)
def pass_pass():
pass
root=Tk()
var = BooleanVar()
w = Canvas(width=250, height=150)
w.pack()
green_circle_tk = PhotoImage(file=green_circle)
red_circle_tk = PhotoImage(file=red_circle)
green_button = Button(root, text="", command=pass_pass)
green_button.config(image=red_circle_tk)
green_button.place(x=20, y=100)
red_button = Button(root, text="", command=pass_pass)
red_button.config(image=green_circle_tk) #,width="40",height="40"
red_button.place(x=20, y=100)
checkbox_2 = Checkbutton(root, text='red/green', variable=var, command=create_image).pack()
root.mainloop()