Why or how does resizeable() solve my “two tk” pro

2020-02-14 07:11发布

问题:

Like many others, I suffered from seeing an 'extra window' titled 'tk'. None of the answers helped, until I stumbled on the solution shown below:

import tkinter as tk
root = tk.Tk()
root.geometry('500x500')

########### Comment out to see the 'two tk' problem
root.resizable(width=False, height=False)
###########

button = tk.Button(root)
button["text"]= 'X'
button.pack()
root.mainloop()

I'm running under OSX 10.15.2, with Python 3.8.

Any ideas? I appreciate it might just be my system, but I am interested in what might be causing this. And it's nothing to do with the IDE - the problem is the same when running direct from Terminal:

$ python3.8 two_tks.py

While 'resizable' solves my problem in the real app, I still would like to solve it. Both Python 3.8 and tkinter and catalina are recent installations

Proof pic:

回答1:

I tried under OSX 10.14.6 with Anaconda Python 3.6.9. However, I had no double window problem.

Maybe there is a problem with the IDE you are using?