8000 Improved selection widget by blink1073 · Pull Request #3502 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Improved selection widget #3502

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 18 commits into from
Nov 13, 2014
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Put onselect in __init__, fix syntax error, make sure lines are anima…
…ted.
  • Loading branch information
blink1073 committed Nov 12, 2014
commit ea732ef0d1f48e8c2d49a483a6c6b3f73dd5fbab
10 changes: 8 additions & 2 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ def __init__(self, ax, onselect, useblit=False, button=None):
AxesWidget.__init__(self, ax)

self.visible = True
self.onselect = onselect
self.connect_default_events()

self.background = None
Expand Down Expand Up @@ -1130,7 +1131,7 @@ def update_background(self, event):
self.background = self.canvas.copy_from_bbox(self.ax.bbox)

def connect_default_events(self):
"""Connect the major canvas events to methods.""""
"""Connect the major canvas events to methods."""
self.connect_event('motion_notify_event', self._onmove)
self.connect_event('button_press_event', self._press)
self.connect_event('button_release_event', self._release)
Expand Down Expand Up @@ -1357,7 +1358,8 @@ def __init__(self, ax, onselect, direction, minspan=None, useblit=False,
def new_axes(self, ax):
self.ax = ax
if self.canvas is not ax.figure.canvas:
self.disconnect_events()
if not self.canvas is None:
Copy link
Member

Choose a reason for hiding this comment

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

flip this to self.canvas is not None please.

self.disconnect_events()

self.canvas = ax.figure.canvas
self.connect_default_events()
Expand Down Expand Up @@ -1572,6 +1574,8 @@ def __init__(self, ax, onselect, drawtype='box',
lineprops = dict(color='black', linestyle='-',
linewidth=2, alpha=0.5)
self.lineprops = lineprops
if useblit:
Copy link
Member

Choose a reason for hiding this comment

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

Should use self.useblit here as it has been semi-validated.

self.lineprops['animated'] = True
self.to_draw = Line2D([0, 0], [0, 0], visible=False,
**self.lineprops)
self.ax.add_line(self.to_draw)
Expand Down Expand Up @@ -1705,6 +1709,8 @@ def __init__(self, ax, onselect=None, useblit=True, lineprops=None,

if lineprops is None:
lineprops = dict()
if useblit:
lineprops['animated'] = True
self.line = Line2D([], [], **lineprops)
self.line.set_visible(False)
self.ax.add_line(self.line)
Expand Down
0