Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tkagg fixes#9275

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
efiring merged 4 commits intomatplotlib:masterfromanntzer:tkagg-anim
Jan 10, 2018
Merged

Tkagg fixes#9275

efiring merged 4 commits intomatplotlib:masterfromanntzer:tkagg-anim
Jan 10, 2018

Conversation

anntzer
Copy link
Contributor

PR Summary

Fix tkagg animation error at exit.

Apparently, with a small enough animation interval, tk does not have the
time to fully proceed through FigureManagerTkAgg.show before the animation
takes over. Removing the call to self.window.update (which had been added
back in 2004 (6c96389), but seems unnecessary (including on Windows)) fixes
the issue (#8107).

Also update the animation example so that it can serve as manual test for
the issue; changed the rate at which the data moves to keep it reasonable,
and switched to None (= count()) as index iterable to avoid a jump every
time we reach the end of the indices.

Deprecations in tkagg.

  • Deprecate passing event to FigureManagerTkAgg.resize (in favor of passing
    width and height separately). This has been "deprecated in comment" for a
    while and is consistent with other backends.
  • Deprecate FigureCanvasTkAgg.show in favor of .draw. This provides the same
    method name as in the other backends.

Cleanup embedding_in_tk, remove embedding_in_tk2.

embedding_in_tk2_sgskip is essentially a slightly simplified duplicate of
embedding_in_tk_sgskip.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswelltacaswell added this to the2.1.1 (next bug fix release) milestoneOct 3, 2017
@dopplershift
Copy link
Contributor

I'm pretty sure that comment from 2004 aboutanim.py actually predates the currentanimation module.

@tacaswelltacaswell modified the milestones:2.1.1 (next bug fix release),2.2 (next feature release)Oct 5, 2017
Apparently, with a small enough animation interval, tk does not havethe time to fully proceed through FigureManagerTkAgg.show before theanimation takes over.  Removing the call to self.window.update (whichhad been added back in 2004 (6c96389), but seems unnecessary (includingon Windows)) fixes the issue.Also update the animation example so that it can serve as manual testfor the issue; changed the rate at which the data moves to keep itreasonable, and switched to None (= count()) as index iterable to avoida jump every time we reach the end of the indices.
This provides the same method name as in the other backends.
@efiring
Copy link
Member

On OS X, the following

(test) efiring@manini2:~/work/programs/py/mpl/matplotlib/examples/animation$ ipythonPython 3.5.2 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:52:12)Type 'copyright', 'credits' or 'license' for more informationIPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.In [1]: import matplotlibIn [2]: matplotlib.use('tkagg')In [3]: run simple_anim.py

hangs with a spinning ball when I close the window with the window manager button. Control-C ends it.
With qt5agg backend, the window closes on command.
It also closes on command with tkagg backend on master, so it looks like this PR might be fixing one problem and introducing another.

@anntzer
Copy link
ContributorAuthor

I see that this patch also adds an error message in the same context as given by@efiring but on Linux:

invalid command name "140521287480648_on_timer"    while executing"140521287480648_on_timer"    ("after" script)

which is not solved by#9956 either.

We probably need to look into clearing the timers at destroy time too. Registering the Timers in a (weak)set and stopping them the the figuremanager's destroy hook doesn't seem to help.

key_press_handler(event, canvas, toolbar)

canvas.mpl_connect('key_press_event', on_key_event)
canvas.mpl_connect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

some debugging code?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Either way works but I guess the previous one looks a bit better. Reverting.

embedding_in_tk2_sgskip is essentially a slightly simplified duplicateof embedding_in_tk_sgskip.
@anntzer
Copy link
ContributorAuthor

Actually, this is the situation on Linux:

  • Original: Keeping the call to update() and the slow interval on the example: no error from command line or ipython
  • Keep the call to update() and switch to fast timer: I get the tk-level error ("invalid command name etc.") and the python traceback (both command line and IPython)
  • Remove the call to update() and keep a slow timer: no error
  • This PR: Remove the call to update and switch to a fast timer: I get the tk-level erroronly from ipython, no error at the command line.

So from this point of view the PR is strictly better, even though it doesn't fix all issues.

Perhaps I can just switch back the example to use an slow timer if the failure mode is more severe on OSX than on Linux (but the same as before the removal of the call to update()).

@anntzer
Copy link
ContributorAuthor

Some further research pointed tohttps://bugs.python.org/issue1252236 (by Matplotlib's own@mdehoon :-)) which indicates that tkinter only checks for events every 20ms (the linestatic int Tkinter_busywaitinterval = 20; is still present in the sources); and, indeed, it looks like the erroneous behavior starts to appear as the interval goes from above 20ms to below (I tried 25 and 15; at 15 you may need to try a few times before reproducing into the issue, probably because this presumably requires some whole interval to occur between two event checks, or something similar).

This doesn't mean that the issue is necessarily unsolvable, but may point out why certain attempts don't work...

@anntzer
Copy link
ContributorAuthor

Would be nice to get this in so that I can make a tkcairo PR that doesn't cause conflicts with this.

@efiringefiring merged commit4f89ef2 intomatplotlib:masterJan 10, 2018
@anntzeranntzer deleted the tkagg-anim branchJanuary 10, 2018 02:38
@anntzeranntzer mentioned this pull requestJan 10, 2018
6 tasks
@QuLogicQuLogic modified the milestones:needs sorting,v2.2.0Feb 12, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@efiringefiringefiring approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
v2.2.0
Development

Successfully merging this pull request may close these issues.

5 participants
@anntzer@dopplershift@efiring@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp