Terry Reedy於 2019年9月9日星期一 UTC+8下午3時06分27秒寫道: > On 9/8/2019 8:40 PM, jf...@ms4.hinet.net wrote: > > > Thank you. After a quick trace to find out the reason, I found that Tkinter > > prevents Tk() be called more than once from widget constructors, so only > > one Tk object exists:-) > > There will only be one default Tk object, but there can be multiple Tk > objects. > > >>> import tkinter as tk > >>> r1 = tk.Tk() > >>> r2 = tk.Tk() > >>> r1.tk > <_tkinter.tkapp object at 0x000001F90F2F1D30> > >>> r2.tk > <_tkinter.tkapp object at 0x000001F90F328930> > > > -- > Terry Jan Reedy
>>> import tkinter as tk >>> f0 = tk.Frame() >>> root0 = tk.Tk() >>> f0.master <tkinter.Tk object at 0x015AB6F0> >>> root0 <tkinter.Tk object at 0x015ABE50> >>> >>> import tkinter as tk >>> root0 = tk.Tk() >>> f0 = tk.Frame() >>> f0.master <tkinter.Tk object at 0x0269B710> >>> root0 <tkinter.Tk object at 0x0269B710> >>> Why? PS. Maybe there is no why, just it is what it is:-) --Jach -- https://mail.python.org/mailman/listinfo/python-list