I want to display a gif in a GUI I am making using tkinter.I have written the code which shows the gif on the GUI , but I am not able to stop it after a given time
def add_gif(window, gif, place_x, place_y, time_after_which_it_should_destroy=3000):
def destroy():
print("destroying...")
label.destroy()
def count(main_gif):
print("counting..")
file = Image.open(main_gif)
print("done")
return file.n_frames
frameCount = count(gif)
frames = [PhotoImage(file=gif, format='gif -index %i' % i) for i in
range(frameCount)] # iterating over the given number of frames
def update(ind):
print(f"updating..{ind}")
frame = frames[ind]
ind += 1
if ind == frameCount:
ind = 0
label.configure(image=frame)
window.after(100, update, ind)
print("running..")
label = Label(window)
print("label made")
label.place(x=place_x, y=place_y)
print("placed")
window.after(time_after_which_it_should_destroy, destroy, update)
I want it to stop showing itself after a given time period