ไม่สามารถแก้ไขตัวแปรส่วนกลางใน python

from tkinter import *
import time

check = False

window = Tk()

window.geometry("1920x1080")

def typeTime():
    hour   = int(time.strftime("%H"))
    minute = int(time.strftime("%M"))
    second = int(time.strftime("%S"))
    hourInput2 = int(hourInput.get())
    minuteInput2 = int(minuteInput.get())
    secondInput2 = int(secondInput.get())
    
    if(hour == hourInput2 and minute == minuteInput2 and second == secondInput2):
        print("now")
    global check
    check = True

canvas = Canvas(window, width = 1980, height = 1020)

canvas.pack()

hourInput = StringVar()
minuteInput = StringVar()
secondInput = StringVar()

setHour = Entry(window, text = hourInput, font = (20)).place(x = 100, y = 20, width = 100, height = 40)

setMinute = Entry(window, text = minuteInput, font = (20)).place(x = 300, y = 20, width = 100, height = 40)

setSecond = Entry(window, text = secondInput, font = (20)).place(x = 500, y = 20, width = 100, height = 40)

canvas.create_text(60, 40, text = "Hour: ", font = (20))

canvas.create_text(260, 40, text = "Minute: ", font = (20))

canvas.create_text(460, 40, text = "Second: ", font = (20))

submit = Button(text = "Submit", height = 2, width = 10, font = (10), command = typeTime)

submit.place(x = 100, y = 100)

if check == True:
    print("Pressed")
    submit.config(relief = SUNKEN)

window.mainloop()

from tkinter import *
import time

if __name__=='__main__':
    check = False

    window = Tk()

    window.geometry("1920x1080")

    def typeTime(button):
        hour   = int(time.strftime("%H"))
        minute = int(time.strftime("%M"))
        second = int(time.strftime("%S"))
        hourInput2 = int(hourInput.get())
        minuteInput2 = int(minuteInput.get())
        secondInput2 = int(secondInput.get())

        if(hour == hourInput2 and minute == minuteInput2 and second == secondInput2):
            print("now")
#         global check
#         check = True
        print('Pressed')
        button.config(relief=SUNKEN)


    canvas = Canvas(window, width = 1980, height = 1020)
    
    canvas.pack()

    hourInput = StringVar()
    minuteInput = StringVar()
    secondInput = StringVar()

    setHour = Entry(window, text = hourInput, font = (20)).place(x = 100, y = 20, width = 100, height = 40)

    setMinute = Entry(window, text = minuteInput, font = (20)).place(x = 300, y = 20, width = 100, height = 40)

    setSecond = Entry(window, text = secondInput, font = (20)).place(x = 500, y = 20, width = 100, height = 40)

    canvas.create_text(60, 40, text = "Hour: ", font = (20))

    canvas.create_text(260, 40, text = "Minute: ", font = (20))

    canvas.create_text(460, 40, text = "Second: ", font = (20))

    submit = Button(text = "Submit", height = 2, width = 10, font = (10))
    submit.config(command = lambda submit=submit:typeTime(submit))

    submit.place(x = 100, y = 100)
    
#     if check == True:
#         print("Pressed")
#         submit.config(relief = SUNKEN)

    window.mainloop()