重置主 GUI 窗口 [英] Resetting the main GUI window

查看:35
本文介绍了重置主 GUI 窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想关闭并重新打开我的主程序.我想在单击下拉菜单中的新"类选项时调用它.类似于调用 root.destroy() 然后重新启动主循环.

我怎样才能完成这项工作?

解决方案

您可以将所有 GUI 构建逻辑和初始状态代码从主循环中取出并放入函数中.从主循环调用这些函数(类似于:buildgui() & initstate()),然后,当用户单击您的菜单图标时,只需调用 initstate() 将其设置回应用程序刚启动时的状态.

I just want the equivalent of closing and reopening my main program. I want to invoke it when a "new"-like option from a drop-down menu is clicked on. Something like calling root.destroy() and then re-initiating the mainloop.

How can I get this done?

解决方案

You could take all your GUI building logic and initial state code out of the mainloop and put it into functions. Call these functions from the mainloop (something like: buildgui() & initstate()) and then, when the user clicks your menu icon, just call initstate() to set it back like it was when the application first started.

这篇关于重置主 GUI 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆