How to change Tkinter Button state from disabled to normal?
I think a quick way to change the options of a widget is using the configure
method.
In your case, it would look like this:
self.x.configure(state=NORMAL)
You simply have to set the state
of the your button self.x
to normal
:
self.x['state'] = 'normal'
or
self.x.config(state="normal")
This code would go in the callback for the event that will cause the Button to be enabled.
Also, the right code should be:
self.x = Button(self.dialog, text="Download", state=DISABLED, command=self.download)
self.x.pack(side=LEFT)
The method pack
in Button(...).pack()
returns None
, and you are assigning it to self.x
. You actually want to assign the return value of Button(...)
to self.x
, and then, in the following line, use self.x.pack()
.