Repository navigation
Add AxesWidget base class to handle event activation and clean up. - #724
Merged
Merged
Conversation
* This change is in preparation for generalizing the base Widget. * It's not clear to me why `new_axes` is necessary, but I left it in (for now).
* Renamed `Lasso.axes` to `Lasso.ax` for consistency. * Remove `Lasso.figure`, which was unused.
* Attribute name "active" can be confused with parameter to `RadioButtons`, but `RadioButtons` doesn't save that parameter as an attribute, so there's no name clash. BUT this is still really confusing to users. Consider renaming `AxesWidget.active`. * * * This could have been implemented as a decorator, but some callbacks wouldn't be compatible. For example, `SpanSelector.release` should not be ignored if widget was deactivated during mouse press. * * * `SpanSelector` and `RectangleSelector` already had `ignore` methods, but they do not call it in `update_background`. I don't change the current behavior, although it seems desirable.
Member
There was a problem hiding this comment.
This is wrong. The cids are not the callback functions themselves, they are the integers returned by the call to mpl_connect().
Contributor
Author
There was a problem hiding this comment.
Good catch! I had this correct at some point, but somehow, I broke it along the way.
Member
|
Overall, I like the idea, and I do see its value in bringing uniformity to the widgets. This does open the doors to subsequent updates. |
Also, remove unused import.
Merged
Class links were incorrect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
connect_eventmethod to connect event and store a reference. Additionaldisconnect_eventsmethod allows user to clean up widget. Some widgets did their own cleanup, but this makes behavior more consistent.ignoremethod and call it in event callbacks. Some widgets had their ownignoremethods, but this makes behavior more consistent.Todo:
SpanSelector.new_axesshould be removed, but may be some user's code depends on it. Right now I duplicate most of thenew_axescode in__init__: Ifnew_axisisn't removed, then duplication should be removed.update_backgroundinSpanSelectorandRectangleSelectordon't ignore events when deactivated.