Another way to change color of a button if you want to do multiple operations along with color change. Using the Tk().after
method and binding a change method allows you to change color and do other operations.
Label.destroy
is another example of the after method.
def export_win():
//Some Operation
orig_color = export_finding_graph.cget("background")
export_finding_graph.configure(background = "green")
tt = "Exported"
label = Label(tab1_closed_observations, text=tt, font=("Helvetica", 12))
label.grid(row=0,column=0,padx=10,pady=5,columnspan=3)
def change(orig_color):
export_finding_graph.configure(background = orig_color)
tab1_closed_observations.after(1000, lambda: change(orig_color))
tab1_closed_observations.after(500, label.destroy)
export_finding_graph = Button(tab1_closed_observations, text='Export', command=export_win)
export_finding_graph.grid(row=6,column=4,padx=70,pady=20,sticky='we',columnspan=3)
You can also revert to the original color.