You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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.
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.
Activity
LindyBalboa commentedon Aug 30, 2016
It seems it inherits through _SelectorWidget and AxesWidget an
activeattribute which when set toFalsewill completely turn off the widget through theignoremethod. 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 commentedon Aug 30, 2016
Just document that setting
w.active = Falseis enough to disable it.We are (long term) planning to move away from all the
get_andset_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
Clean up SpanSelector documentation
Clean up SpanSelector documentation
Clean up SpanSelector documentation
Clean up SpanSelector documentation