简体   繁体   English

Python tkinter 主窗口也会关闭所有其他窗口,为什么?

[英]Python tkinter main window closes all other windows too, why?

I made a gui programm with Tkinter.我用 Tkinter 做了一个 gui 程序。 In the program are several buttons which open new main tkinter windows but when i click on the 'x' of one of these windows all the other ones close too although they are different windows.在程序中有几个按钮可以打开新的主 tkinter 窗口,但是当我单击这些窗口之一的“x”时,所有其他窗口也会关闭,尽管它们是不同的窗口。 Only the Buttons, which cause the new tkinter main windows, are in the same main window.只有导致新 tkinter 主窗口的按钮位于同一主窗口中。

please help :))请帮忙 :))

This is how tkinter is designed to work.这就是 tkinter 的设计方式。 When you destroy a window, all of its children are destroyed.当你销毁一个窗口时,它的所有子窗口都会被销毁。 Since everything is a child of the root window or one of its children, when you destroy the root window all other widgets are destroyed along with it.由于一切都是根窗口的子窗口或其子窗口之一,因此当您销毁根窗口时,所有其他小部件都会随之销毁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM