Im starting to learn python and tkinter code, im gettint some troubles doing this simple windows whith a button, and when the button was pressed it should disable itself.
#the complete error-------------------------
*File "C:\Users\a441868\Desktop\proyecto aplicacion it suport\venv\prueba botones.py", line 4, in toggle_state if button1.cget("state") == "normal": AttributeError: 'NoneType' object has no attribute 'cget' Exception in Tkinter callback Traceback (most recent call last): File "C:\python\lib\tkinter_init_.py", line 1921, in call return self.func(args)
#code--------------------
def toggle_state():
if button1.cget("state") == "normal":
button1.config(state="disabled")
label1.config(text='COMPLETADO',bg='green')
return
else:
button1.config(state="normal")
label1.config(text='PENDIENTE')
root = Tk()
root.geometry('400x400')
button1 = Button(root, text="Exportar marcadores Chrome",command=toggle_state).grid(column=0,row=0)
root.mainloop()