0

What I'm trying to do is click twice on the canvas and get the event.x and event.y for both the mouse clicks so I can use it draw primitives.

I would like to use the two sets of event values to calculate the distance and use it as a radius to draw circle.

At the moment I am able to get it only for a single click.

def leftClick(event=None):
    print("left",event.x,event.y)

c.bind("<Button-1>",leftClick)
r4bb1t
  • 1,033
  • 2
  • 13
  • 36
  • 1
    Your event handler will need to have a "state" so it know whether the click is the first or second. If you make it part of a class, it can store the first click's coordinates as `self` attributes. – martineau Dec 16 '19 at 03:00
  • 1
    Instead of two isolated mouse clicks, it might be better to make the user move the mouse with the button down between the two positions called "drag and drop" — you could even draw temporary circles shoing the current size defined while this is happening. Tkinter doesn't have any direct support for this, so see [How make Drag and Drop interface?](https://stackoverflow.com/questions/44887576/how-make-drag-and-drop-interface) for some ideas on how to implement it. – martineau Dec 16 '19 at 07:23
  • This sounds good, thank you very much – r4bb1t Dec 16 '19 at 13:37

1 Answers1

0

You can try binding it with

c.bind('<Double-Button-1>', function)

And define the function as per your requirements

Hardik Jain
  • 247
  • 2
  • 10