Tkinter Button muss in bestimmten Zeitpunkt gedrückt werden?

Ich möchte mit tkinter (Python) einen Button machen, der in einer bestimmten Zeit gedrückt werden muss, ansonsten soll

print("failedTime")

ausgegeben werden.

Mein Code:

from tkinter import *
import random

xr = 40
yr = 40

global hitButton

def restartGame():
    root.destroy()
    Main()

def noCommand():
    print("no command executed")

def failEvent():
    global hitButton
    print("failed")
    OverLabel = Label(image=GameOverIMG)
    OverLabel.place(x=200, y=80)
    print("test")
    hitButton.place(x=232323, y=232323)
    bRestart = Button(root, text="Restart", fg="WHITE", bg="BLACK", command=restartGame, width=5, height=3)
    bRestart.place(x=200, y=700)

def ButtonHitEvent():
    global xr
    global yr
    xr = random.randint(40, 1800)
    yr = random.randint(40, 1000)
    hitButton.place(x=xr, y=yr)

def Main():
    global hitButton
    global ButtonImg
    global ClearIMG
    global clearLabelGameOver
    global ButtonWindow
    global hitButton
    global GameOverIMG
    global root

    root = Tk()
    root.geometry("1920x1080")

    ButtonImg = PhotoImage(file="C:/Users/jakob/AppData/Local/Programs/Python/Python39/Scripts/Scripts/Python/Tkinter/graphics/ButtonClick.png")
    GameOverIMG = PhotoImage(file="C:/Users/jakob/AppData/Local/Programs/Python/Python39/Scripts/Scripts/Python/Tkinter/graphics/GameOver.png")
    ClearIMG = PhotoImage(file="C:/Users/jakob/AppData/Local/Programs/Python/Python39/Scripts/Scripts/Python/Tkinter/graphics/clear.png")

    clearLabelGameOver = Label(root, image=ClearIMG)
    clearLabelGameOver.place(x=300, y=200)

    ButtonWindow = Button(root, text=" ", width=300, height=300, command=failEvent, background="BLACK", foreground="BLACK").pack()

    hitButton = Button(root, image=ButtonImg, command=ButtonHitEvent, fg="BLACK", bg="BLACK")
    hitButton.place(x=40, y=40)

    root.mainloop()

if __name__ == '__main__':
    Main()
Computer, programmieren, Python, Tkinter
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.