Search code examples
pythontkinterevent-binding

How do I bind an event to the left mouse button being held down?


I need a command to be executed as long as the left mouse button is being held down.


Solution

  • Look at table 7-1 of the docs. There are events that specify motion while the button is pressed, <B1-Motion>, <B2-Motion> etc.

    If you're not talking about a press-and-move event, then you can start doing your activity on <Button-1> and stop doing it when you receive <B1-Release>.