How to draw a rectangle using event handler ?

Hello world!
I am displaying on my screen a set of data corresponding to points
defined by a longitude and latitude.
The display is fine with the command imshow (mydata ,...)

I would like now associate to the application a callback that draw a rectangle
on two consecutive left mouse's button press defined by its two
opposite vertices.
(also returns points) and a right click button that erases the rectangle.

I found the event_handling example, but I do not know how to do this.
May someone helps me?
Thank's a lot in advance.

Yagua

Hi Yagua,

Hello world!
I am displaying on my screen a set of data corresponding to points
defined by a longitude and latitude.
The display is fine with the command imshow (mydata ,...)

I would like now associate to the application a callback that draw a
rectangle on two consecutive left mouse's button press defined by its two
opposite vertices.
(also returns points) and a right click button that erases the rectangle.

Why don't you want for select the rectangle using the rectangle selector?
I attached an example (modified version of example 'rectangle_selector.py')
showing its usage. You can delete lines using the key 'd' or 'D'.

Furthermore I attached a script, which uses button_press_event s as you
proposed above.

I hope at least one of the examples helps you.

Kind regards,
Matthias

draw_rectangle_using_button_press_events.py (1.36 KB)

draw_rectangle_using_rectangle_selector.py (2.52 KB)

ยทยทยท

On Friday 12 February 2010 17:04:27 Yagua Rovi wrote: