-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move widget.{get,set}_active to AxisWidget. #3376
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
Move widget.{get,set}_active to AxisWidget. #3376
Conversation
The method was previously defined only for RectangleSelectors (matplotlib#3375). Also, an redundant line was removed (RectangleSelectors are already set active on __init__ by the superclass).
Could you also property-ify it while you are at it? |
And this will need to be documented in |
Because selectors must update their background on set_active(True), widget.active was made a property for backwards compatibility.
Because _Selector is a private class there are no references to the actual getter and setter in the rst file.
You added it to the 1.4.0 whats_new section, this should be under the 1.5.0 section. |
class SpanSelector(AxesWidget): | ||
class _SelectorWidget(AxesWidget): | ||
def set_active(self, active): | ||
super(_SelectorWidget, self).set_active(active) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a good of an idea is it seems, because we aren't using super every where can you hard-code the over loading?
The reason I am worried is that if this ends up in an MRO where not everything is cooperating, you can get strange bugs. If we are going to go down this route, everything in the AxesWidget
class strucutre also needs to use super
.
If this doesn't go in a bugfix release of 1.4, there should at least be an indication in the docstrings of the Selector classes that changing the underlying background when the selector is not active is (was) not supported (if |
This seems to me to be too big of a change to go into a bug-fix release. I don't fully understand your comment. |
My point is that this is not just an API change; the previous behaviour is actually buggy. Consider the
Now, if you try to use the lasso selector after an update of the dynamic canvas, the canvas will go back to the original plot. The reason is that |
@@ -1081,7 +1093,21 @@ def _update(self): | |||
self.canvas.draw_idle() | |||
|
|||
|
|||
class SpanSelector(AxesWidget): | |||
class _SelectorWidget(AxesWidget): | |||
def set_active(self, active): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should over-ride the property as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell, is this the only thing holding this PR up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at this again, it does update, the property method is tricksy.
Ah, it was not clear that this was also fixing a bug and I missed the behavior change reading through. @mdboom @efiring I am inclined to leave this just on 1.5, if it is broken in 1.4 it has been broken for a long time and widgets are not as widely used as they should/could be. It is not worth picking this apart to back-port just the bug fix. I can also be convinced that this whole thing should be back-ported. |
... so it should dynamically retrieve the set_active method.
I agree that breaking the patch apart for the sake of it is a bit overkill, although there are nearly no API changes and one could even remove the |
@blink1073 I will try to take a look at this tomorrow. |
Okay, my suggestion would be for me to handle the change in my PR in lieu of waiting. |
ENH : Move widget.{get,set}_active to AxisWidget.
@blink1073 I re-read this now and my concern was addressed with out me realizing it. I am against back-porting this change to 1.4.x. |
Blitting is not used in matplotlib GTK3Cairo backend, disabled here as well. SpanSelector and RectangleSelector now have same properties "active" and "visible" (see matplotlib/matplotlib#3376 ) FIXME: On layout change, more than one SpanSelector appears on Graph
The method was previously defined only for RectangleSelectors (#3375).
Also, an redundant line was removed (RectangleSelectors are already set
active on init by the superclass).