Tkinter button problem

Fredrik Lundh effbot at telia.com
Wed Mar 8 13:39:45 EST 2000


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