I'm just starting making simple python GUIs. I was working on this one right here and when I run it the rectangle is static. Is there any fixes that would make the rectangle move 50 px horizontally every second? I've been working on trying to fix it but haven't had any success.
from tkinter import *
import time
rectMove = True
class rectMove():
def __init__(self):
root = Tk()
frame = Frame(root, width=500, height=500)
frame.grid()
canvas = Canvas(frame, width=500, height=500)
canvas.grid()
firstX = 50
firstY = 50
secondX = 100
secondY = 100
rectangle = canvas.create_rectangle(firstX, firstY, secondX, secondY, fill="Black")
while rectMove is True:
rectangle.destroy()
time.sleep(1)
firstX += 50
secondX += 50
rectangle = canvas.create_rectangle(firstX, firstY, secondX, secondY, fill="Black")
root.mainloop()
rectMove = rectMove()