How do I hold forever when the <Down> key is pressed and gain +10? (Python3 + Tkinter)

Asked

Viewed 51 times

0

from tkinter import *
from tkinter import messagebox
jan = Tk()
jan.geometry("500x500")

Quadrado = Frame(jan,bg="#B0C4DE", width=25, height=25, bd=3, relief="raise")
Quadrado.place(x=50, y=50)





def moveUp(event):
    print("Key Up")


jan.bind("<Up>", moveUp)
def moveDown(event):
    y = 60
    try_01 = 0
    try_01 = int(try_01)
    Quadrado.place(y=y)
    while try_01 <= 10:
        y += 10
        try_01 += 1





jan.bind("<Down>", moveDown)




jan.mainloop()
  • The "y" serves as a geometric meter of the place (y=y) function ex: (y=70)

1 answer

1


y = 10
def moveDown(event):
    global y
    try_01 = 0
    try_01 = int(try_01)
    Quadrado.place(y=y)
    while try_01 <= 10:
        y += 10
        try_01 += 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.