Double Click Mouse Event in Tkinter

Fredrik Lundh fredrik at pythonware.com
Sat Jan 7 19:26:48 CET 2006


"scott_gui" wrote:

> Creating a Windows application:
> <Double-Button-1> mouse event has a conflict when there is also a
> binding to the <Button-1> event. It seems like a silly oversight that
> performing a double click will also initiate the single click action.

If your design depends on your code being able to accurately figure out what
the user will do in the future, you may want to go back to the drawing board.

> Has anyone figured out a way to circumvent this problem? Right now I am
> making the Double click function undo the action my Single click
> function does, but this is very annoying, especially since the action
> that is bound to the Single click flashes for a second.

I don't think I've ever seen any recent application that does this (be-
cause all possible "solutions" are annoying), but I seem to recall that
the Explorer in some early version of Windows overloaded single and
double click actions by delaying the single click action (click and wait =
single click action, click and click = double click action).

To implement this in Tkinter, you can schedule an "after" task in the
Button-1 handler, and cancel it in the Double-Button-1 handler.  But
a redesign is probably a better idea...

</F>






More information about the Python-list mailing list