How do I make a button use it's command whenever it is active? For example, if you hold a repeating button for 1 second, it should have executed it's command about 250 to 1000 times already right? But with a regular button, it just executes it one time, until you release the mouse and click it again. How can I make a button like that? I currently have this with moving,
def up(player):
x = 0
y = -10
c.move(player.rect,x,y)
def down(player):
x = 0
y = 10
c.move(player.rect,x,y)
def left(player):
x = -10
y = 0
c.move(player.rect,x,y)
def right(player):
x = 10
y = 0
c.move(player.rect,x,y)
#functions are in a class called player
p = player(sx1=950,sy1=540,sx2=975,sy2=565)
lup = lambda : tk.after(50,p.up)
upbtn = Button(tk,width=3,height=2,text="↑",command=lup)
upbtn.pack()
upbtn.place(x=960,y=700)
mainloop()
I searched on the web, but it didn't show any results consistent with my problem. Thanks in advance!