Reputation: 1
I have a variable for example: x = 1. And I want to change it to x = 2 using a tkinter button.
I tried:
b1 = Button(root,bg = "black",fg = "white",text = "idk",command = (x=2))
Upvotes: 0
Views: 51
Reputation: 86
U can call a function on command to set your global variable
x=3
b1 = Button(root,bg = "black",fg = "white",text = "idk",command = vall)
def vall():
global x
x=2
Upvotes: 2