Search code examples
pythontkinterkey-bindings

Tkinter binding mouse double click


I'm trying to bind my mouse double click to a function which for now just prints the current selection in a Tkinter list box. To be clear the function should only print when the user double clicks on one of the items of a Tkinter list box. What event binding should I use?


Solution

  • You can bind to <Double-Button-1>:

    widget.bind('<Double-Button-1>', handler)
    

    There is also <Button-1> for normal mouse clicks and <Triple-Button-1> for a triple mouse click.

    For more information on bindings in Tkinter, see Events and Bindings.