When the button is clicked, the button should change to orange but its not.
from tkinter import *
root = Tk()
root.geometry('300x300')
def clicked():
global clicks
Here is the code for color change
button.configure(background = 'orange')
button = Button(root, justify=CENTER,text = "Click Me!", command=clicked)
button.pack()
root.mainloop()
I only changed the order of your code.
from tkinter import *
def clicked():
global clicks
button.configure(background = 'orange')
root = Tk()
root.geometry('300x300')
button = Button(root, justify=CENTER,text = "Click Me!", command=clicked)
button.pack()
root.mainloop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.