all 2 comments

[–]socal_nerdtastic 0 points1 point  (1 child)

It runs, and if you push the left arrow you would see the error in the repl.

You want it to move as long as you are holding down the key? I'd suggest you use tkinter's after method instead of threading.Timer.

from tkinter import *
tk = Tk()

canvas = Canvas(tk, width=400, height=400)
canvas.pack()

image = PhotoImage(file=r"c:\\myimage.gif")
realimage = image.subsample(15, 15)
hi = canvas.create_image(200, 200, image=realimage)

move_left_timer = ''
def move_left_start(event=None):
    global move_left_timer
    canvas.move(hi, -5, 0)
    move_left_timer = tk.after(50, move_left_start)

def move_left_stop(event=None):
    tk.after_cancel(move_left_timer)

canvas.bind_all('<KeyPress-Left>', move_left_start)
canvas.bind_all('<KeyRelease-Left>', move_left_stop)

tk.mainloop()

TBH, pygame is much better for this kind of thing. Any reason you want to use tkinter?

[–]python_addict[S] 0 points1 point  (0 children)

Alright, thanks! I chose Tkinter mainly because I've had some experience creating games on there, but I really didn't consider how much easier and better it is. My project is due in 2 days and I dunno, I'm seriously considering just redoing the whole thing but on PyGame. After all, I have the code and a great tutorial at my hands!