Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

figure_enter_event uses now LocationEvent instead of Event. Fix issue #9812.#9814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
efiring merged 4 commits intomatplotlib:masterfromlkjell:fix_figure_enter_event
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletionlib/matplotlib/backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2010,8 +2010,14 @@ def enter_notify_event(self, guiEvent=None, xy=None):
if xy is not None:
x, y = xy
self._lastx, self._lasty = x, y
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you add a warning here like

warnings.warn('enter_notify_event expects a location but your backend did not pass one. ''This may become mandatory in the future',stacklevel=2)

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

cbook.warn_deprecated?

x = None
y = None
cbook.warn_deprecated('3.0', 'enter_notify_event expects a '
'location but '
'your backend did not pass one.')

event =Event('figure_enter_event', self, guiEvent)
event =LocationEvent('figure_enter_event', self, x, y, guiEvent)
self.callbacks.process('figure_enter_event', event)

@cbook.deprecated("2.1")
Expand Down
7 changes: 7 additions & 0 deletionslib/matplotlib/backends/_backend_tk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,6 +178,8 @@ def __init__(self, figure, master=None, resize_callback=None):
self._tkcanvas.bind("<Configure>", self.resize)
self._tkcanvas.bind("<Key>", self.key_press)
self._tkcanvas.bind("<Motion>", self.motion_notify_event)
self._tkcanvas.bind("<Enter>", self.enter_notify_event)
self._tkcanvas.bind("<Leave>", self.leave_notify_event)
self._tkcanvas.bind("<KeyRelease>", self.key_release)
for name in "<Button-1>", "<Button-2>", "<Button-3>":
self._tkcanvas.bind(name, self.button_press_event)
Expand DownExpand Up@@ -326,6 +328,11 @@ def motion_notify_event(self, event):
y = self.figure.bbox.height - event.y
FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)

def enter_notify_event(self, event):
x = event.x
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))

def button_press_event(self, event, dblclick=False):
x = event.x
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/backends/backend_gtk3.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,7 +225,10 @@ def leave_notify_event(self, widget, event):
FigureCanvasBase.leave_notify_event(self, event)

def enter_notify_event(self, widget, event):
FigureCanvasBase.enter_notify_event(self, event)
x = event.x
# flipy so y=0 is bottom of canvas
y = self.get_allocation().height - event.y
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))

def size_allocate(self, widget, allocation):
dpival = self.figure.dpi
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_qt5.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -299,7 +299,8 @@ def get_width_height(self):
return int(w / self._dpi_ratio), int(h / self._dpi_ratio)

def enterEvent(self, event):
FigureCanvasBase.enter_notify_event(self, guiEvent=event)
x, y = self.mouseEventCoords(event.pos())
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This can just beself.enter_notif_event(guiEvent=event, xy=(x, y))

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could do but that would break some inconsistency with the other event as well. For example

def wheelEvent(self, event):    x, y = self.mouseEventCoords(event)    # from QWheelEvent::delta doc    if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:        steps = event.angleDelta().y() / 120    else:        steps = event.pixelDelta().y()    if steps:        FigureCanvasBase.scroll_event(self, x, y, steps, guiEvent=event)def keyPressEvent(self, event):    key = self._get_key(event)    if key is not None:        FigureCanvasBase.key_press_event(self, key, guiEvent=event)def keyReleaseEvent(self, event):    key = self._get_key(event)    if key is not None:        FigureCanvasBase.key_release_event(self, key, guiEvent=event)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fair. I suppose those could also all be changed to normal method calls, but that is beyond the scope of this PR.


def leaveEvent(self, event):
QtWidgets.QApplication.restoreOverrideCursor()
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/backends/backend_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1053,7 +1053,10 @@ def _onLeave(self, evt):

def _onEnter(self, evt):
"""Mouse has entered the window."""
FigureCanvasBase.enter_notify_event(self, guiEvent=evt)
x = evt.GetX()
y = self.figure.bbox.height - evt.GetY()
evt.Skip()
FigureCanvasBase.enter_notify_event(self, guiEvent=evt, xy=(x, y))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This can also just beself.enter_notify_event.



class FigureCanvasWx(_FigureCanvasWxBase):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp