Trying to get the rectangle to shrink and then rise, but if I uncomment the rise_step() call, it rises up, but never comes down again. And if I leave it rise_step() commented out, it shrinks, but doesn't come back up
Here's my code
import tkinter as tk
root = tk.Tk()
c = tk.Canvas(root, width=400, height=400, bg='white')
c.pack()
def draw_step(x=0):
if x > 801:
return
value = x * 0.1
c.delete("rect") # clear previous rectangle
c.create_rectangle(95, 95 + value, 145, 188, fill="red", outline='', tags="rect")
c.after(10, draw_step, x + 1) # smaller delay = smoother motion
def rise_step(x=0):
if x > 801:
return
value = x * 0.1
c.delete("rect") # clear previous rectangle
c.create_rectangle(95, 95 - value, 145, 188, fill="red", outline='', tags="rect")
c.after(10, rise_step, x + 1) # smaller delay = smoother motion
draw_step()
# rise_step()
root.mainloop()