Update the status of a widget in tkinter

0

I've been trying to make a button in tkinter update. The thing is that putting what I thought was right and the solutions of other Stackoverflow questions, still does not work. The example:

def cambiacolor(): boton.config(bg= "Gray")

boton = Button(root,text="tocame para cambiar de color", bg = "Lightblue")

The thing is that as I have done it and with the module .update_idletasks() do not work.

Any solution?

    
asked by Esteban 05.11.2018 в 18:54
source

1 answer

0
from tkinter import Tk, Button

ventana = Tk()
ventana.geometry("200x100+100+100")

def cambiacolor(boton):
    boton.config(bg= "Gray")


btn_color = Button(ventana, text="tocame para cambiar de color", bg="Lightblue", command=lambda:cambiacolor(btn_color))
btn_color.place(x=15, y=25)
    
answered by 09.11.2018 в 15:09