If statements in GUI

Hi everyone, i am very new to all this, and i was wondering if you could use any if statement as follows when a button has been pressed within a GUI? or is there is there something i am missing?

n = 1
def Helloworld():
if n == 1:
n = 0
print(“hello to you too!!”)
ledbutton[“text”]=“Goodbye”
else:
n = 1
print(“goodbye to you too!!”)
ledButton[“text”]=“Hello”

def close():
win.destroy()