Tkinter window not opening Tkinter window not opening tkinter tkinter

Tkinter window not opening


These problems are generally solved with the use of classes, which you should learn and use before coding GUIs IMHO. You should not use time() as it can interrupt the infinite Tkinter loop. Use Tkinter's after() instead. Also, you never set moveBoolean to False, so the while statement runs until the program is cancelled, and the second time through the square will be off the canvas, which is why you don't get anything visible. The following solves your problems but again would be better if a class structure were used.

from tkinter import *from functools import partialcanvas_height = 400canvas_width = 600canvas_colour = "grey50"moveBoolean = "True"def move_it(ctr=0):    if ctr < len(coords):        x, y = coords[ctr]        ctr += 1        print ctr, x, y        canvas.move(square, x, y)        window.after(1000, partial(move_it, ctr))window = Tk()canvas = Canvas(bg=canvas_colour, height=canvas_height,         width=canvas_width, highlightthickness=0)canvas.pack()square = canvas.create_rectangle(50, 50, 50, 50, width=50, fill="black")coords = ((90, 90),          (180, 180),          (50, 50))move_it()window.mainloop()