tkinter button state = DISABLED

rahulnag22 at yahoo.com rahulnag22 at yahoo.com
Mon May 14 16:46:32 EDT 2007


On May 14, 12:01 pm, Peter Otten <__pete... at web.de> wrote:
> rahulna... at yahoo.com wrote:
> > I have created a button widget with a button click binding. The button
> > initially has a state=disabled. I can see the greyed out version of
> > the button in the GUI. But If I click on the button it still invokes
> > the callback/binding function.
>
> > Any suggestions as to why the callback is being invoked even though
> > the button has a disabled state. It looks like-
>
> > b=Button(frame,  text = "Button", state = 'disabled')
>
> > b.bind("<ButtonRelease-1>",
> >                         lambda
> >                         event :
> > function()
> > )
>
> Well, the /mouse/ button /was/ released. Do you know about the alternative?
>
> b = Button(..., command=function) # no bind(), no lambda
>
> It behaves like you expect.
>
> Peter


So, then is it right to say that for a widget like button widget on
occurance of a 'event' the function which is bound to this event is
invoked, even if the button widget has its 'state' option set to
'disabled'. I was assuming that if the button widget has state =
'disabled' then even on a button event the binding function wont be
invoked.
I will take a look at the alternative code you suggested above too.

Thanks
Rahul




More information about the Python-list mailing list