-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Provide way to disable Multi Cursor (Implement #2663) #4225
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
Conversation
Implemented MultiCursor disable function
Could you move the If you are feeling ambitious, making sure that all of the sub-classes make proper use of |
Done. Moved all the active logic up to the Widget class. And removed the basic ignore functions from the subclasses. |
Great. I am a bit wary of the class level attribute which it silently made an instance attribute when you assign to it, but do anything about that until someone else weighs in. attn @efiring @mdboom @blink1073 |
also attn @WeatherGod |
IMO |
That was my initial thoughts as well. But the AxesWidget takes in only single axis and all the child classes only require one so this would be the odd one out. It would also require modifications in all the subclasses of AxesWidget to check type; more ambition! Or perhaps for the single axes case make a single element tuple? But still requires modification to the subclasses. |
I was in the process of typing out what @JayP16 said. |
@tacaswell, you are referring to the _active attribute? I don't see any problem with this. It seems to me that this idiom makes the code more compact and makes it easier to see what the attributes are. What is it that makes you wary of it? |
I have to agree with @tacaswell, class-level attributes turned into On Tue, Mar 17, 2015 at 5:05 PM, Eric Firing [email protected]
|
oh, wow... I never noticed that there were those other class-level attributes! That is unfortunate, and I now need an excedrin. |
@efiring Yes. It is is part as Ben says a source of headaches/confusion. If seems like a nice way to do default state, but it might open up a can of worms with mutable values (which |
@WeatherGod Why? I still don't understand the problem. Does this idiom introduce some risk? Is it any harder to understand than, say, properties? It seems straightforward to me, and something that can enhance rather than reduce readability. I think it is quite common. It is similar to the situation where module-level variables turn into local variables via assignment in a function. That's actually something I try to avoid, but in the case of classes, it seems natural to me. |
do class-level attributes get inherited upon subclassing? I thought they didn't. |
@tacaswell, OK, so it requires a bit of care, to avoid mutable variables. |
I was just looking at http://ioam.github.io/param/index.html, which depends on this type of behavior, including the inheritance. I think traitlets also use this idiom of class-level initialization. I need to look. |
Those are a bit different though as they are using meta-class magic to turn the class level attributes into instance level properties, right? |
At least in params, the conversion into instance attributes happens only when a value is changed, so it is very much like the simple case. I don't know how traitlets handles them. |
It looks like HasTraits initialization causes immediate instance-level initialization of all Traits, so this is handled differently than in params. |
Any suggestions on what should be done? It would be problematic if it were mutable; which _active is not, like @tacaswell mentioned. Do we want a initialize method in widgets; can we see a use for it in the future? |
Sorry, this PR discussion went off on a tangent (part of a rolling conversation @efiring and I are having). Eric convinced me that it is fine as implemented. |
@@ -1061,6 +1061,8 @@ def disconnect(self): | |||
|
|||
def clear(self, event): | |||
"""clear the cursor""" | |||
if self.ignore(event): |
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.
Clear should probably work even if the widget is not 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.
If this behavior is consistent with the other widgets then disregard my last comment.
Only other comment is that it might be worth starting the deprecation process on the |
Can you also add an entry into https://github.com/matplotlib/matplotlib/tree/master/doc/users/whats_new It should be documented that all |
ping @JayP16 re whats_new entry. |
Sorry for the delay. It's been created. :) |
ENH/API : Provide way to disable MultiCursor, move enable logic to Widget
@JayP16 Thank you! |
Implemented MultiCursor disable function. Now can disable the multi cursor the same way as Cursor; using "cursor.active = False"
( #2663)