So I'm trying to make an automatic TicTacToe GUI that will play you back once you move. The code you see is very layman as the actual code is very long and generally out of context. I want the code itself to work so that when the button is clicked, the value of A1 will change to 1 and it will check if the value is 1 so it can print, "This is a test" if so.
I've already tried global, I don't know if I'm doing it wrong or not. Is there any other way of doing this withought assigning a different Variable?
from tkinter import *
root = Tk()
A1 = 0
def btn_change():
global A1
A1 += 1
Button1 = Button(root, text=" ", command=btn_change)
Button1.pack()
if A1 == 1:
print("This is a test.")
root.mainloop()
When I run the code, the window looks fine, but when I press the button on the screen, it doesn't display "This is a test." In other words, it's just blank.