{{ message }}
Regenerate background when RectangleSelector active-flag is set back on. - #17480
Merged
Merged
Conversation
Member
Member
|
And if so, maybe this should override |
Contributor
Author
|
set_active calls update_background, so that's fine? |
QuLogic
approved these changes
Oct 2, 2020
Member
|
|
Member
|
Wait, I forgot to set Also affects |
Contributor
Author
|
Do you have an example where this can easily be checked? Is that just a matter of moving the |
Member
|
I essentially patched the examples to do what diff --git a/examples/widgets/polygon_selector_demo.py b/examples/widgets/polygon_selector_demo.py
index c1340679f3..68de0e0e9a 100644
--- a/examples/widgets/polygon_selector_demo.py
+++ b/examples/widgets/polygon_selector_demo.py
@@ -50,9 +50,17 @@ class SelectFromCollection:
elif len(self.fc) == 1:
self.fc = np.tile(self.fc, (self.Npts, 1))
- self.poly = PolygonSelector(ax, self.onselect)
+ self.poly = PolygonSelector(ax, self.onselect, useblit=False)
self.ind = []
+ self.cid = self.canvas.mpl_connect('key_press_event',
+ self.toggle_selector)
+
+ def toggle_selector(self, event):
+ if event.key == 't':
+ self.poly.set_active(not self.poly.active)
+ print('Selector toggled')
+
def onselect(self, verts):
path = Path(verts)
self.ind = np.nonzero(path.contains_points(self.xys))[0]
diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.py
index 2e720f4c98..3955c8f540 100644
--- a/examples/widgets/span_selector.py
+++ b/examples/widgets/span_selector.py
@@ -46,9 +46,17 @@ def onselect(xmin, xmax):
#
+def toggle_selector(event):
+ if event.key == 't':
+ span.set_active(not span.active)
+ print('Span toggled')
+
+
span = SpanSelector(ax1, onselect, 'horizontal', useblit=True,
rectprops=dict(alpha=0.5, facecolor='red'))
# Set useblit=True on most backends for enhanced performance.
+fig.canvas.mpl_connect('key_press_event', toggle_selector)
+
plt.show() |
Contributor
Author
Otherwise, if the selector is made inactive and then back to active, the "old" selector gets captured in the background image and spurious appears. No tests because good luck with that, but can be tried with examples/widgets/rectangle_selector.py.
This was referenced Oct 2, 2020
6 tasks
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.

Otherwise, if the selector is made inactive and then back to active, the
"old" selector gets captured in the background image and spurious
appears.
No tests because good luck with that, but can be tried with
examples/widgets/rectangle_selector.py.
Closes #17476.
PR Summary
PR Checklist