Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d3bb78

Browse files
committed
FIX: be forgiving about the event for enterEvent not having a pos
closes #11607 The event object passed in from PyQt4 does not have a `pos` attribute. Be forgiving of this and fallback to None. This matches the fallback behavior in backend_bases if xy is not passed to `enter_notify_event`.
1 parent 0f05cf4 commit 5d3bb78

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ def get_width_height(self):
291291
return int(w / self._dpi_ratio), int(h / self._dpi_ratio)
292292

293293
def enterEvent(self, event):
294-
x, y = self.mouseEventCoords(event.pos())
294+
try:
295+
x, y = self.mouseEventCoords(event.pos())
296+
except AttributeError:
297+
# the event from PyQt4 does not include the position
298+
x = y = None
295299
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))
296300

297301
def leaveEvent(self, event):

0 commit comments

Comments
 (0)