-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
MEP22: Navigation by events #3652
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
Changes from 1 commit
8cceed4
3118a5a
b4d5fcf
1e8af47
622cb95
d1a9de4
3f89d52
4f3c10b
6065daa
f6a2f19
05db3b6
c08fe56
b207a72
9266447
a53419a
704c717
5056729
e6a4e1e
8942c47
022de6f
2c9a195
cafe668
224f745
94c711e
67257e7
ffa65d6
6739ee0
d18206f
34a52c8
c2da483
44a9b0e
a2ed47f
0665890
411e6e2
d484ebd
75bf97b
6cc040b
0ff5997
af6734f
78513d2
377ff54
7dbbf58
dd66b57
67a414f
e415d8d
1213086
ba61dec
9f2ee2b
9da2b13
110253f
e2804ea
9a64b7e
64f947f
e8cd5d5
4bbcf4e
73a2661
1b83628
e4edd23
d4ac2fb
a7640ef
48a6971
8dafe09
a0695d0
328b169
aac4744
f09b9ef
def3a52
9ee7e25
5eae4e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,31 +72,14 @@ class ToolBase(object): | |
| `name` is used as label in the toolbar button | ||
| """ | ||
|
|
||
| toggle = False # Change the status (take control of the events) | ||
| """Is toggleable tool | ||
|
|
||
| **bool**: | ||
|
|
||
| * **True**: The tool is a toogleable tool | ||
| * **False**: The tool is not toggleable | ||
|
|
||
| """ | ||
|
|
||
| persistent = False | ||
| """Is persistent tool | ||
|
|
||
| **bool**: | ||
| * `True`: The tool is persistent | ||
| * `False`: The tool is not persistent | ||
| """ | ||
|
|
||
| cursor = None | ||
| """Cursor to use when the tool is active | ||
| """ | ||
|
|
||
| def __init__(self, figure, event=None): | ||
| self.figure = figure | ||
| self.navigation = figure.canvas.manager.navigation | ||
| self.figure = None | ||
| self.navigation = None | ||
| self.set_figure(figure) | ||
| self.trigger(event) | ||
|
|
||
| def trigger(self, event): | ||
|
|
@@ -109,6 +92,18 @@ def trigger(self, event): | |
| """ | ||
| pass | ||
|
|
||
| def set_figure(self, figure): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would do everything as properties, rather than stand-alone setters.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always prefer properties, but in this case, if it is going to be overwritten by the tool creator, it is too easy to forget to add the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not fully sold on that, it is just as easy to forget to override
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are overriding
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you think on adding Not a fan of this double function, but solves both of our problems
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @OceanWolf Use case. Here I am advancing myself, but for single figure, it is not that useful because you can just do whatever you want to do after @tacaswell I usually do the same public/private, but in this case, I was trying to get normal users to be able to play easily and create tools easily. So far, if you want to customize your plot window in any way, it requires a lot of internal code knowledge
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fariza Okay, I will take your word for that, just when you say "
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case of MEP23, this is useful when a tool need access to the new and old figure. But if you insist, and I agree that for this MEP is not that important,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tacaswell @OceanWolf done. I guess you are right, I am being just stubborn
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not for the moment set the figure directly in the Not against it, just trying to adhere to the KISS principle 😉., and atm it looks like unneeded complexity. |
||
| """Set the figure and navigation | ||
|
|
||
| Set the figure to be affected by this tool | ||
|
|
||
| Parameters | ||
| ---------- | ||
| figure : `Figure` | ||
| """ | ||
| self.figure = figure | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be |
||
| self.navigation = figure.canvas.manager.navigation | ||
|
|
||
|
|
||
| class ToolPersistentBase(ToolBase): | ||
| """Persisten tool | ||
|
|
@@ -121,12 +116,13 @@ class ToolPersistentBase(ToolBase): | |
| The difference with `ToolBase` is that `trigger` method | ||
| is not called automatically at initialization | ||
| """ | ||
| persistent = True | ||
|
|
||
| def __init__(self, figure, event=None): | ||
| self.figure = figure | ||
| self.navigation = figure.canvas.manager.navigation | ||
| self.figure = None | ||
| self.navigation = None | ||
| self.set_figure(figure) | ||
| #persistent tools don't call trigger a at instantiation | ||
| #it will be called by Navigation | ||
|
|
||
| def unregister(self, *args): | ||
| """Unregister the tool from the instances of Navigation | ||
|
|
@@ -145,7 +141,6 @@ class ToolToggleBase(ToolPersistentBase): | |
| Every time it is triggered, it switches between enable and disable | ||
|
|
||
| """ | ||
| toggle = True | ||
| _toggled = False | ||
|
|
||
| def trigger(self, 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.
Is there a use-case for a Tool that does not implement it's own
trigger? If there is not (and you don't plan to use multiple inheritance) I suggest this raiseNotImplementedThere 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.
Yes there is, if you look at
backend_tools.ToolViewsPositionsdoesn't use atriggermethodThere 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.
ok. sorry for the noise.