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

Appearance settings

Make draggable callbacks check that artist has not been removed. #10908

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2018
Merged
Changes from all 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
17 changes: 12 additions & 5 deletions 17 lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,8 +1615,8 @@ def finalize_offset(self):
*update_offset* places the artists simply in display
coordinates. And *finalize_offset* recalculate their position in
the normalized axes coordinate and set a relavant attribute.

"""

def __init__(self, ref_artist, use_blit=False):
self.ref_artist = ref_artist
self.got_artist = False
Expand All @@ -1631,14 +1631,14 @@ def __init__(self, ref_artist, use_blit=False):
self.cids = [c2, c3]

def on_motion(self, evt):
if self.got_artist:
if self._check_still_parented() and self.got_artist:
dx = evt.x - self.mouse_x
dy = evt.y - self.mouse_y
self.update_offset(dx, dy)
self.canvas.draw()

def on_motion_blit(self, evt):
if self.got_artist:
if self._check_still_parented() and self.got_artist:
dx = evt.x - self.mouse_x
dy = evt.y - self.mouse_y
self.update_offset(dx, dy)
Expand All @@ -1647,7 +1647,7 @@ def on_motion_blit(self, evt):
self.canvas.blit(self.ref_artist.figure.bbox)

def on_pick(self, evt):
if evt.artist == self.ref_artist:
if self._check_still_parented() and evt.artist == self.ref_artist:

self.mouse_x = evt.mouseevent.x
self.mouse_y = evt.mouseevent.y
Expand All @@ -1668,14 +1668,21 @@ def on_pick(self, evt):
self.save_offset()

def on_release(self, event):
if self.got_artist:
if self._check_still_parented() and self.got_artist:
self.finalize_offset()
self.got_artist = False
self.canvas.mpl_disconnect(self._c1)

if self._use_blit:
self.ref_artist.set_animated(False)

def _check_still_parented(self):
if self.ref_artist.figure is None:
self.disconnect()
return False
else:
return True

def disconnect(self):
"""disconnect the callbacks"""
for cid in self.cids:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.