ボタンの再描画が失敗するのはなぜですか?最初にボタンがある場所で起動し、次に上部のウィンドウのサイズを低くしてから、ボタンを別のサイズに縮小したいのですが、buttononTop()メソッドからのボタンの再描画が失敗します。
#!/usr/bin/python
import pygtk, gtk, gobject
class GTK_Main:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_default_size(800, 768)
self.window.connect("destroy", gtk.main_quit, "WM destroy")
self.vbox = gtk.VBox()
self.window.add(self.vbox)
self.hbox = gtk.HBox(False, 0)
self.vbox.pack_start(self.hbox, False)
self.hbox.set_border_width(10)
self.hbox.pack_start(gtk.Label(), True, True, 0)
self.button2 = gtk.Button("Quit")
self.button2.connect("clicked", self.exit)
self.hbox.pack_start(self.button2, False)
self.button3 = gtk.Button("Test")
self.button3.connect("clicked", self.buttononTop)
self.hbox.pack_start(self.button3, False)
self.hbox.add(gtk.Label())
self.window.show_all()
def buttononTop(self, w):
print "Buttons on top - redraw with different shapes includeing the window"
self.window.remove(self.vbox)
self.window.resize(800, 330)
self.window.set_size_request(800, 330)
# ------------------------------------------- [FAILS STARTS]
self.vbox = gtk.VBox()
self.window.add(self.vbox)
self.hbox = gtk.HBox(False, 0)
self.vbox.pack_start(self.hbox, False)
self.hbox.set_border_width(10)
self.hbox.pack_start(gtk.Label(), True, True, 0)
self.button2 = gtk.Button("Quit")
self.button2.connect("clicked", self.exit)
self.hbox.pack_start(self.button2, False)
self.button3 = gtk.Button("Test")
self.button3.connect("clicked", self.buttononTop)
self.hbox.pack_start(self.button3, False)
self.hbox.add(gtk.Label())
# ------------------------------------------- [FAILS END]
def exit(self, widget, data=None):
gtk.main_quit()
GTK_Main()
gtk.gdk.threads_init()
gtk.main()