Tkinter button problem

Thomas Lane tom at parlant.com
Wed Mar 8 16:32:34 EST 2000


Fredrik,

Thank you for your help. This did the trick. I'm learning something new
every day. I appreciate the help, and I'm sure all the other Tkinter
newbies who use this newsgroup appreciate your contributions also. Thank
you.

Tom

Fredrik Lundh wrote:
> 
> Thomas Lane <tom at parlant.com> wrote:
> > In a Tkinter program that I am writing, I have noticed that buttons that
> > caise a dialog to open stay "pressed" (ie. they are still sunken) when
> > the dialog returns. Buttons that do a command of some sort (ie. don't
> > open a dialog) seem to behave normally. Is this normal?
> 
> not really.  you seem to be doing something weird here...
> 
> > Is there a way to force a button to its non-sunken state before returning
> > from my button-click event handler?
> 
> event handler?  you shouldn't be using event handlers to
> catch button clicks.  using the "command" option instead
> should fix this.
> 
> or in other words, it sounds as if you're doing:
> 
>     b = Button(root, text="foo") # Button = button widget
>     b.bind("<Button-1>", callback) # Button = mouse button
> 
> instead of:
> 
>     b = Button(root, text="foo", command=callback)
> 
> (note that the command callback takes no arguments,
> while an event handler takes an event descriptor as its
> only argument)
> 
> </F>



More information about the Python-list mailing list