如何在 Gtk 中恢复应用程序的默认设置(将所有小部件设置为应用程序重新启动时的状态)?
我想实现一个“新建”按钮,它在大多数应用程序中与“文件>新建”的工作方式相同 - 即:将所有标签、树视图等重置为原始状态。
谢谢你,托马斯
I would like to implement a button "New" that would work the same as File>New in most applications - that is: resets all the labels, treeviews, etc. to the original state.
Thank you, Tomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
小部件不记得它们的原始状态;你必须把它们一一设置回去。为标签提供原始文本,通过将其模型设置为
None
来清除树视图。如果你有窗户的话,也许最好毁掉你的窗户,然后从你的 Glade 文件中重建它?
The widgets don't remember their original state; you have to set them all back one by one. Give labels their original text, clear the tree views by setting their model to
None
.Perhaps it is better to destroy your window and rebuild it from your Glade file if you have one?