I’m trying to make a function that changes slides in an animated presentation by using if statements, but when the slide is supposed to change, the existing widget stays. Here is my minimal reproducible example (by the way, the ‘description.insert’ is formatted correctly on my computer but not on my phone):
from tkinter import *
import random
import time
tk = Tk()
canvas = Canvas(tk, width = 400, height = 400)
tk.title('Diffusion')
canvas.pack()
slide = 0
def changeSlide():
global slide
slide += 1
#WRITE TEXT
if slide == 1:
description = Text(tk, bd=0, height=5, width = 50)
description.insert(INSERT, 'Diffusion is the net movement of particles from an area of higher concentration to an area of lower concentration, which results in the concentration being even. Here is an example, with the particles represented by orange dots:')
description.place(x=0, y=190)
elif slide == 2:
#DRAW PARTICLES
particle = canvas.create_oval(10, 10, 20, 20, fill = 'orange')
nexT = Button(tk, text = 'NEXT', command = changeSlide)
nexT.pack()
nexT.place(bordermode = 'inside', x = 350, y = 375)
Aucun commentaire:
Enregistrer un commentaire