I need to change the state from DISABLED
to NORMAL
of a Button
when some event occurs.
Here is the current state of my Button, which is currently disabled:
self.x = Button(self.dialog, text="Download",
state=DISABLED, command=self.download).pack(side=LEFT)
self.x(state=NORMAL) # this does not seem to work
Can anyonne help me on how to do that?
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:
This is what worked for me. I am not sure why the syntax is different, But it was extremely frustrating trying every combination of activate, inactive, deactivated, disabled, etc. In lower case upper case in quotes out of quotes in brackets out of brackets etc. Well, here's the winning combination for me, for some reason.. different than everyone else?
You simply have to set the
state
of the your buttonself.x
tonormal
:or
This code would go in the callback for the event that will cause the Button to be enabled.
Also, the right code should be:
The method
pack
inButton(...).pack()
returnsNone
, and you are assigning it toself.x
. You actually want to assign the return value ofButton(...)
toself.x
, and then, in the following line, useself.x.pack()
.