0

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()

1 Answers1

0

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()
thomkell
  • 195
  • 1
  • 11