SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: John H. <jd...@gm...> - 2008年11月26日 19:05:28
I recently added support for a figure/axes enter/leave event. The
figure enter and axes enter/leave are easy to do with nothing new in
the backends, just using the native mpl events. The figure leave
event is harder, because when a user leaves a figure and activates
another window, mpl gets no events.
To correct this, I added a leave_notify_event method to
backend_bases.FigureCanvasBase (note this is not an mpl Event) but
when called it will trigger a callback to those registered to the
figure_leave_event with the last event that occurred in the window.
I added support for this in gtk by connecting the the gtk signal
'leave_notify_event' to the mpl backend method leave_notify_event. If
you know something about tk, wx or qt event handling, could you add a
similar method to the appropriate backend? You can follow the example
in backend_gtk.
You can test with examples/event_handling/figure_axes_enter_leave.py
Thanks,
JDH
From: Darren D. <dsd...@gm...> - 2008年11月27日 13:05:17
I can have a look at the qt backends, maybe this weekend.
On Wed, Nov 26, 2008 at 2:05 PM, John Hunter <jd...@gm...> wrote:
> I recently added support for a figure/axes enter/leave event. The
> figure enter and axes enter/leave are easy to do with nothing new in
> the backends, just using the native mpl events. The figure leave
> event is harder, because when a user leaves a figure and activates
> another window, mpl gets no events.
>
> To correct this, I added a leave_notify_event method to
> backend_bases.FigureCanvasBase (note this is not an mpl Event) but
> when called it will trigger a callback to those registered to the
> figure_leave_event with the last event that occurred in the window.
>
> I added support for this in gtk by connecting the the gtk signal
> 'leave_notify_event' to the mpl backend method leave_notify_event. If
> you know something about tk, wx or qt event handling, could you add a
> similar method to the appropriate backend? You can follow the example
> in backend_gtk.
>
>
> You can test with examples/event_handling/figure_axes_enter_leave.py
>
> Thanks,
> JDH
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-devel mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
From: Darren D. <dsd...@gm...> - 2008年11月30日 22:04:25
On Wed, Nov 26, 2008 at 2:05 PM, John Hunter <jd...@gm...> wrote:
> I recently added support for a figure/axes enter/leave event. The
> figure enter and axes enter/leave are easy to do with nothing new in
> the backends, just using the native mpl events. The figure leave
> event is harder, because when a user leaves a figure and activates
> another window, mpl gets no events.
>
> To correct this, I added a leave_notify_event method to
> backend_bases.FigureCanvasBase (note this is not an mpl Event) but
> when called it will trigger a callback to those registered to the
> figure_leave_event with the last event that occurred in the window.
>
> I added support for this in gtk by connecting the the gtk signal
> 'leave_notify_event' to the mpl backend method leave_notify_event. If
> you know something about tk, wx or qt event handling, could you add a
> similar method to the appropriate backend? You can follow the example
> in backend_gtk.
>
>
> You can test with examples/event_handling/figure_axes_enter_leave.py
>
I implemented this in backend_qt4.
Darren
From: Gregor T. <gre...@gm...> - 2008年12月02日 14:35:03
Attachments: leave.diff
John Hunter schrieb:
> I recently added support for a figure/axes enter/leave event. The
> figure enter and axes enter/leave are easy to do with nothing new in
> the backends, just using the native mpl events. The figure leave
> event is harder, because when a user leaves a figure and activates
> another window, mpl gets no events.
>
> To correct this, I added a leave_notify_event method to
> backend_bases.FigureCanvasBase (note this is not an mpl Event) but
> when called it will trigger a callback to those registered to the
> figure_leave_event with the last event that occurred in the window.
>
> I added support for this in gtk by connecting the the gtk signal
> 'leave_notify_event' to the mpl backend method leave_notify_event. If
> you know something about tk, wx or qt event handling, could you add a
> similar method to the appropriate backend? You can follow the example
> in backend_gtk.
>
>
> You can test with examples/event_handling/figure_axes_enter_leave.py
>
> Thanks,
> JDH
I attached a patch for the wx backend. Nearly everything has already 
been implemented. Instead of the new 'leave_notify_event' leaving the 
figure triggered a fake motion_event. I changed this.
If a mouse button is pressed while leaving the figure the behaviour is 
somewhat strange. First, a figure_leave_event is emitted. Then, further 
moving the mouse outside the figure a new figure_enter_event is created. 
This is the case since all mouse events, also movements outside the 
window, are captured as long as a mouse button is pressed. This is a 
very convenient behaviour for panning/zooming. However, when finally 
releasing the mouse button no figure_leave_event is triggered. With the 
GTK backend such an event is created.
So what should be the desired behaviour?
Gregor
From: John H. <jd...@gm...> - 2008年12月02日 15:41:57
On Tue, Dec 2, 2008 at 8:34 AM, Gregor Thalhammer
<gre...@gm...> wrote:
> If a mouse button is pressed while leaving the figure the behaviour is
> somewhat strange. First, a figure_leave_event is emitted. Then, further
> moving the mouse outside the figure a new figure_enter_event is created.
> This is the case since all mouse events, also movements outside the window,
> are captured as long as a mouse button is pressed. This is a very convenient
> behaviour for panning/zooming. However, when finally releasing the mouse
> button no figure_leave_event is triggered. With the GTK backend such an
> event is created.
> So what should be the desired behaviour?
Ahh, I hadn't considered this problem. It arises because I am using
mpl location events to trigger the figure enter event. The solution
is to use the gui event for the figure enter event too -- basically
the gui needs to call the canvas.enter_notify_event. I added your
patch and modified gtk to handle the enter_notify_event in svn r6468.
Can you update, repatch wx to use it (and Darren qt)?
Any takers out their to add support to tk?
Thanks,
JDH
From: Darren D. <dsd...@gm...> - 2008年12月02日 17:19:38
On Tue, Dec 2, 2008 at 10:41 AM, John Hunter <jd...@gm...> wrote:
> On Tue, Dec 2, 2008 at 8:34 AM, Gregor Thalhammer
> <gre...@gm...> wrote:
>
> > If a mouse button is pressed while leaving the figure the behaviour is
> > somewhat strange. First, a figure_leave_event is emitted. Then, further
> > moving the mouse outside the figure a new figure_enter_event is created.
> > This is the case since all mouse events, also movements outside the
> window,
> > are captured as long as a mouse button is pressed. This is a very
> convenient
> > behaviour for panning/zooming. However, when finally releasing the mouse
> > button no figure_leave_event is triggered. With the GTK backend such an
> > event is created.
> > So what should be the desired behaviour?
>
> Ahh, I hadn't considered this problem. It arises because I am using
> mpl location events to trigger the figure enter event. The solution
> is to use the gui event for the figure enter event too -- basically
> the gui needs to call the canvas.enter_notify_event. I added your
> patch and modified gtk to handle the enter_notify_event in svn r6468.
> Can you update, repatch wx to use it (and Darren qt)?
This is done for qt and qt4. In qt, if you hold the button, leave the
figure, enter the second figure, and release the button, the old figure
receives the leave event, but the new figure does not receive the enter
event. This seems like an issue with qt3, the new figure does receive the
enter event with qt4.
I noticed that if one moves the cursor rapidly through the figure and axes,
some events are not captured. For example, the cursor is in an axes but the
last event the axes received was a leave event. I'm not sure how that could
be improved, do you see it as well?
Finally, off topic, I committed the improved version checking in
mpl.__init__, using subprocess instead of popen*, which were deprecated in
python-2.6. This has been tested on two separate windows machines, hopefully
there are no lurking issues. But its something to keep in mind when we cut
the next release for windows.
Darren
From: Gregor T. <gre...@gm...> - 2008年12月03日 12:43:31
Attachments: enter.diff
>
> Can you update, repatch wx to use it (and Darren qt)?
>
I attached a patch that emits a enter_notify_event if the mouse enters the
figure. Now the example behaves correctly.
Gregor
From: John H. <jd...@gm...> - 2008年12月03日 18:38:54
On Wed, Dec 3, 2008 at 6:43 AM, Gregor Thalhammer
<gre...@gm...> wrote:
>> Can you update, repatch wx to use it (and Darren qt)?
>
> I attached a patch that emits a enter_notify_event if the mouse enters the
> figure. Now the example behaves correctly.
Thanks Gregor -- just committed this. I don't have any other feedback
on the other points you and Darren are discussing yet....
JDH
From: Gregor T. <gre...@gm...> - 2008年12月03日 14:26:51
2008年12月2日 Darren Dale <dsd...@gm...>
>
>
> On Tue, Dec 2, 2008 at 10:41 AM, John Hunter <jd...@gm...> wrote:
>
>> On Tue, Dec 2, 2008 at 8:34 AM, Gregor Thalhammer
>> <gre...@gm...> wrote:
>>
>> > If a mouse button is pressed while leaving the figure the behaviour is
>> > somewhat strange. First, a figure_leave_event is emitted. Then, further
>> > moving the mouse outside the figure a new figure_enter_event is created.
>> > This is the case since all mouse events, also movements outside the
>> window,
>> > are captured as long as a mouse button is pressed. This is a very
>> convenient
>> > behaviour for panning/zooming. However, when finally releasing the mouse
>> > button no figure_leave_event is triggered. With the GTK backend such an
>> > event is created.
>> > So what should be the desired behaviour?
>>
>> Ahh, I hadn't considered this problem. It arises because I am using
>> mpl location events to trigger the figure enter event. The solution
>> is to use the gui event for the figure enter event too -- basically
>> the gui needs to call the canvas.enter_notify_event. I added your
>> patch and modified gtk to handle the enter_notify_event in svn r6468.
>> Can you update, repatch wx to use it (and Darren qt)?
>
>
> This is done for qt and qt4. In qt, if you hold the button, leave the
> figure, enter the second figure, and release the button, the old figure
> receives the leave event, but the new figure does not receive the enter
> event. This seems like an issue with qt3, the new figure does receive the
> enter event with qt4.
>
with the patched wx backend I observe the same behaviour. The second figure
does not recieve an enter event. This might be because the wx backend
captures the mouse if a button is pressed, i.e., all mouse events are
redirected to the first figure.
> I noticed that if one moves the cursor rapidly through the figure and
axes, some events are not captured. For example, the cursor is in an axes
but the last event the axes received was a leave event. I'm not sure how
that could be improved, do you see it as well?
Exactly this behaviour I can't see with the wx backend. Did I understood
correctly: You manage to place the mouse within an axis, without having
received a enter event?
With all backends (Wx, GTK, Qt) I manage to leave the figure, without
leaving an axis. Either I move very fast, or I stack the figures on screen
so that I can leave an axis without touching the space around. We could emit
axes_leave_events (to all axes of the figure, or do we keep record which
axes has been entered recently?) before emitting a figure_leave_event, or
leave this to the users implementation of the figure_leave_event callback.
The first solution might lead to a lot of undesired redraws of the figure
when leaving the figure if several axes are contained in the figure and each
leave_axes callback issues a redraw, like in the example.
Gregor
From: Darren D. <dsd...@gm...> - 2008年12月03日 15:00:51
On Wed, Dec 3, 2008 at 9:26 AM, Gregor Thalhammer <
gre...@gm...> wrote:
>
>
> 2008年12月2日 Darren Dale <dsd...@gm...>
>
>>
>>
>> On Tue, Dec 2, 2008 at 10:41 AM, John Hunter <jd...@gm...> wrote:
>>
>>> On Tue, Dec 2, 2008 at 8:34 AM, Gregor Thalhammer
>>> <gre...@gm...> wrote:
>>>
>>> > If a mouse button is pressed while leaving the figure the behaviour is
>>> > somewhat strange. First, a figure_leave_event is emitted. Then, further
>>> > moving the mouse outside the figure a new figure_enter_event is
>>> created.
>>> > This is the case since all mouse events, also movements outside the
>>> window,
>>> > are captured as long as a mouse button is pressed. This is a very
>>> convenient
>>> > behaviour for panning/zooming. However, when finally releasing the
>>> mouse
>>> > button no figure_leave_event is triggered. With the GTK backend such an
>>> > event is created.
>>> > So what should be the desired behaviour?
>>>
>>> Ahh, I hadn't considered this problem. It arises because I am using
>>> mpl location events to trigger the figure enter event. The solution
>>> is to use the gui event for the figure enter event too -- basically
>>> the gui needs to call the canvas.enter_notify_event. I added your
>>> patch and modified gtk to handle the enter_notify_event in svn r6468.
>>> Can you update, repatch wx to use it (and Darren qt)?
>>
>>
>> This is done for qt and qt4. In qt, if you hold the button, leave the
>> figure, enter the second figure, and release the button, the old figure
>> receives the leave event, but the new figure does not receive the enter
>> event. This seems like an issue with qt3, the new figure does receive the
>> enter event with qt4.
>>
>
> with the patched wx backend I observe the same behaviour. The second figure
> does not recieve an enter event. This might be because the wx backend
> captures the mouse if a button is pressed, i.e., all mouse events are
> redirected to the first figure.
>
> > I noticed that if one moves the cursor rapidly through the figure and
> axes, some events are not captured. For example, the cursor is in an axes
> but the last event the axes received was a leave event. I'm not sure how
> that could be improved, do you see it as well?
>
> Exactly this behaviour I can't see with the wx backend. Did I understood
> correctly: You manage to place the mouse within an axis, without having
> received a enter event?
>
Yes, this is the behavior I see.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /