正如你可以看到这个例子,如果我们关闭然后再显示包含gtk.Label的窗口 - 标签也显示,但如果窗口包含gtk.Image - 我们看不到它。
import gtk,gobject
def dest(*a):
print 1
gobject.timeout_add(1000,dest2)
#also, why it is impossible to show window again at once it closed?
def dest2(*a):
print 2
win.add(child)
win.show_all()
shild.queue_draw()
print 'where is is?'
win = gtk.Window()
win.connect('delete-event', dest)
l = gtk.Label('gtk')
image=gtk.Image()
f=fopen('some_image.png','r')
loader = gtk.PixbufLoader()
loader.write(f.read())
loader.close()
f.close()
image.set_from_pixbuf(loader.get_pixbuf())
child=image
#child=l #so, if uncomment this string - everything is perfect
win.add(child)
win.show_all()
gtk.main()
答案 0 :(得分:0)
@scythargon
什么是shild.queue_draw()?无论如何:
def dest2(*a):
print 2
image.set_from_pixbuf(loader.get_pixbuf()) # <<<---- add this "and your hair will be soft and silky"
win.add(child)
win.show_all()
# shild.queue_draw()
print 'where is is?'
我的pygtk说:loader = gtk.gdk.PixbufLoader()
#也是,为什么一旦它关闭就不可能再次显示窗口?
您可以尝试在dest()
中使用“return True”