Skip to content
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

No good way to disable SpanSelector #7009

Closed
LindyBalboa opened this issue Aug 30, 2016 · 2 comments
Closed

No good way to disable SpanSelector #7009

LindyBalboa opened this issue Aug 30, 2016 · 2 comments
Milestone

Comments

@LindyBalboa
Copy link
Contributor

LindyBalboa commented Aug 30, 2016

1.5.1 Python3.5

So it seems SpanSelector has no built in method to shut down. The docs say "For the selector to remain responsive you must keep a reference to it." but even without a reference, the behavior persists. I attempted doing a del spanSelector but the behavior persisted.

The docs suggest doing spanSelector.set_visible(False) but in order to turn it back on again, one must use spanSelector.set_visible(True). This automatically shows the last selected span, which is probably not a desirable default behavior.

from matplotlib import pyplot as plt
import matpltotlib

ax = plt.subplot(111)
def onSelect(m,n):
    print(m,n)
s = matplotlib.widgets.SpanSelector(ax, onSelect, 'horizontal')
s.set_visible(False)
s.set_visible(True)
@LindyBalboa
Copy link
Contributor Author

It seems it inherits through _SelectorWidget and AxesWidget an active attribute which when set to False will completely turn off the widget through the ignore method. Should a setter method be added or only make mention of the attribute in the docs?

Otherwise, I still don't understand why the operates if the widget is deleted.

@tacaswell
Copy link
Member

Just document that setting w.active = False is enough to disable it.

We are (long term) planning to move away from all the get_ and set_ methods to properties/traitlets.

Are you sure something else does not keep a reference to it? It only goes away if it gets garbage collected (as the callbacks only hold a weakref to it). It is also possible that SpanSelector (unlike the other widgets) inserts a reference to it's self. If so, that should be tracked down an fixed.

The widgets are sorely under documented.

Also see #5786

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Aug 30, 2016
LindyBalboa pushed a commit to LindyBalboa/matplotlib that referenced this issue Sep 6, 2016
Add reference to AxesWidget.active for disabling the selector.

Resolves matplotlib#7009
LindyBalboa pushed a commit to LindyBalboa/matplotlib that referenced this issue Sep 8, 2016
Add reference to AxesWidget.active for disabling the selector.

Resolves matplotlib#7009
LindyBalboa pushed a commit to LindyBalboa/matplotlib that referenced this issue Sep 8, 2016
Add reference to AxesWidget.active for disabling the selector.

Resolves matplotlib#7009
LindyBalboa pushed a commit to LindyBalboa/matplotlib that referenced this issue Sep 8, 2016
Add reference to AxesWidget.active for disabling the selector.

Resolves matplotlib#7009
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants