重新打开 PyGtk 窗口为空
我正在与 Glade 合作,使用 PyGTK 制作一个简单的 GUI 应用程序。我有两个窗口,一个仅在按下按钮时显示。
def on_preview_clicked(self, widget):
print "You clicked the Preview button"
prev = self.builder.get_object("previewWindow")
prev.show()
该窗口工作正常,但如果我关闭它并尝试再次打开它,它就会变成空的。 我在谷歌上发现这可能是因为我指的窗口被“破坏”了,所以我把窗口隐藏了。
def hide_preview(self, widget):
print "Hide it!"
prev = self.builder.get_object("previewWindow")
prev.hide()
return True
这没有任何作用,第二次窗口仍然是空的。 我缺少什么?
I am working with Glade to make a simple GUI application using PyGTK. I have two windows, one only showing up when a button is pressed.
def on_preview_clicked(self, widget):
print "You clicked the Preview button"
prev = self.builder.get_object("previewWindow")
prev.show()
The window is working fine, but if I close it, and try to open it again, it becomes empty.
I found on google that it may be because the window I am referring to was "destroyed", so I made the window hide instead.
def hide_preview(self, widget):
print "Hide it!"
prev = self.builder.get_object("previewWindow")
prev.hide()
return True
This did nothing, the window still comes up empty the second time around.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有有效的测试用例,很难确定,但尝试将其从
show()
更改为show_all()
,以确保窗口也显示。Without a working testcase of this, it's difficult to be sure, but try changing it from
show()
toshow_all()
, to be sure that all the child widgets of the window are shown as well.