-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Widget and animation improvements #3985
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -569,24 +569,39 @@ def _clicked(self, event): | |
if event.inaxes != self.ax: | ||
return | ||
|
||
for p, t, lines in zip(self.rectangles, self.labels, self.lines): | ||
for i, (p, t) in enumerate(zip(self.rectangles, self.labels)): | ||
if (t.get_window_extent().contains(event.x, event.y) or | ||
p.get_window_extent().contains(event.x, event.y)): | ||
l1, l2 = lines | ||
l1.set_visible(not l1.get_visible()) | ||
l2.set_visible(not l2.get_visible()) | ||
thist = t | ||
self.set_active(i) | ||
break | ||
else: | ||
return | ||
|
||
def set_active(self, index): | ||
""" | ||
Directly (de)activate a check button by index. | ||
|
||
*index* is an index into the original label list | ||
that this object was constructed with. | ||
Raises ValueError if *index* is invalid. | ||
|
||
Callbacks will be triggered if :attr:`eventson` is True. | ||
|
||
""" | ||
if 0 > index >= len(self.labels): | ||
raise ValueError("Invalid CheckButton index: %d" % index) | ||
|
||
l1, l2 = self.lines[index] | ||
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. super picky, would this be clearer as for ln is self.lines[index]:
ln.set_visible(not ln.get_visible()) |
||
l1.set_visible(not l1.get_visible()) | ||
l2.set_visible(not l2.get_visible()) | ||
|
||
if self.drawon: | ||
self.ax.figure.canvas.draw() | ||
|
||
if not self.eventson: | ||
return | ||
for cid, func in six.iteritems(self.observers): | ||
func(thist.get_text()) | ||
func(self.labels[index].get_text()) | ||
|
||
def on_clicked(self, func): | ||
""" | ||
|
@@ -698,17 +713,31 @@ def inside(p): | |
pcirc = np.array([p.center[0], p.center[1]]) | ||
return dist(pclicked, pcirc) < p.radius | ||
|
||
for p, t in zip(self.circles, self.labels): | ||
for i, (p, t) in enumerate(zip(self.circles, self.labels)): | ||
if t.get_window_extent().contains(event.x, event.y) or inside(p): | ||
inp = p | ||
thist = t | ||
self.value_selected = t.get_text() | ||
self.set_active(i) | ||
break | ||
else: | ||
return | ||
|
||
for p in self.circles: | ||
if p == inp: | ||
def set_active(self, index): | ||
""" | ||
Trigger which radio button to make active. | ||
|
||
*index* is an index into the original label list | ||
that this object was constructed with. | ||
Raise ValueError if the index is invalid. | ||
|
||
Callbacks will be triggered if :attr:`eventson` is True. | ||
|
||
""" | ||
if 0 > index >= len(self.labels): | ||
raise ValueError("Invalid RadioButton index: %d" % index) | ||
|
||
self.value_selected = self.labels[index].get_text() | ||
|
||
for i, p in enumerate(self.circles): | ||
if i == index: | ||
color = self.activecolor | ||
else: | ||
color = self.ax.get_axis_bgcolor() | ||
|
@@ -720,7 +749,7 @@ def inside(p): | |
if not self.eventson: | ||
return | ||
for cid, func in six.iteritems(self.observers): | ||
func(thist.get_text()) | ||
func(self.labels[index].get_text()) | ||
|
||
def on_clicked(self, func): | ||
""" | ||
|
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.
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.
why turn off blitting?
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 the animation goes on, the limits keep changing. When blitting is turned
on, you don't see the x-axis change, which is incorrect. Turn blitting off,
and you see the scale change correctly.
On Thu, Jan 8, 2015 at 10:12 PM, Thomas A Caswell notifications@github.com
wrote:
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.
ah, ok. If you move the mouse in and out it triggers a full re-draw (at least on qt) which updates them so I thought it was always updating correctly.
There probably should be some logic someplace in the animation that if any has change to do a full-redraw.
This actually ties back into what @efiring and I were talking about to make pyplot behave better as well as it wouldn't be too hard to co-op that system to allow non-animated artists to make the axes as 'dirty' which would trigger a full-redraw.
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.
Wouldn't need to do that. The animation module already attaches a reset of
the blit to frame resizes, we just never attached it to other kinds of
changes.
I don't know why it doesn't make a difference for you though. A full redraw
isn't sufficient. The bbox copy has to be reset.
On Jan 8, 2015 10:32 PM, "Thomas A Caswell" notifications@github.com
wrote:
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.
I thought that the animation code added hooks so that on a redraw event it takes care of re-copying the blit box not to resizes spcefically.
What is going on on my system (I think) is that when you mouse in/out qt triggers a full re-paint (as there may have been silly alpha stuff going on when the window was non-focused (oh, right I also use focus follow mouse so I am really changing the focus state) ) and that repaint from the windowing system bubbles down and does a full re-draw of the canvas which updates the tick labels.
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.
That might be the case. It was a long time ago that Ryan and I worked on
that part. If that is the case, then a focus-follows-mouse setup would
trigger a redraw and thus reset the blit. In any case, let's focus on the
other questions for this PR: 1) should we use indexes or string labels and
2) should the check button's set_active() allow for explicit setting of the
state rather than strictly toggling?
On Thu, Jan 8, 2015 at 11:11 PM, Thomas A Caswell notifications@github.com
wrote: