tkinter button state = DISABLED

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon May 14 17:27:30 EDT 2007


En Mon, 14 May 2007 17:46:32 -0300, <rahulnag22 at yahoo.com> escribió:

> On May 14, 12:01 pm, Peter Otten <__pete... at web.de> wrote:
>> rahulna... at yahoo.com wrote:
>> > 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.
>
> 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.

Maybe there is a confusion here. You code above means that, when the event  
"The leftmost MOUSE BUTTON was released" happens over your BUTTON WIDGET  
b, your function will be called.
The "alternative code" suggested is the right way; the "command" is fired  
when the mouse button is pressed inside the widget AND then released  
inside the SAME widget (and the button is not disabled).

-- 
Gabriel Genellina




More information about the Python-list mailing list