This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkinter root window does not close if used with matplotlib.pyplot
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: paul.moore, psiehr, serhiy.storchaka, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-08-30 15:34 by psiehr, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg301028 - (view) Author: Philipp (psiehr) Date: 2017-08-30 15:34
Today I ran into a problem when using both tkinter and matplotlib.pyplot at the same time. I thought it would be best to let you know, in case it is an issue. 

The problem is/was that the root window did not close itself, when just using `askopenfilename()`. 

A complete description of the problem, including a minimal working example, screenshots and a "solution" can be found on StackOverflow: 
https://stackoverflow.com/q/45960815/7414040 

I think that the function `askopenfilename()` does not ensure that the tkinter root window, that has been opened, is destroyed after the function call ended.
msg301032 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-08-30 16:52
This is purely a tkinter issue.  Windows people can ignore this.

Your problem was a result of your program error, of not keeping a reference to Tk(), combined with tkinter's _default_root 'feature'.

The solution you report in your answer, 'root = tkinter.Tk()', later followed by an explicit 'root.destroy()' is *the* correct way to do what you want.  I explained further in my answer.

There is no way for askopenfilename to know that you are done with root or tkinter._default_root.
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75490
2017-08-30 16:52:57terry.reedysetstatus: open -> closed

assignee: terry.reedy ->
components: - IDLE, Windows
versions: + Python 3.7, - Python 3.5
nosy: + serhiy.storchaka

messages: + msg301032
resolution: not a bug
stage: resolved
2017-08-30 15:34:35psiehrcreate