def __expandpreferences(self, params=None): """ Callback to expand the window for preferences. """ # We have a race condition here. If GTK cant resize fast enough, then it gets very sluggish # See configure-event signal of gtk.Widget # start timer, resize, catch configure-notify, set up idle handler, when idle resize to what the size should be at this point of time, repeat if hasattr(self, 'expandtimeout'): self.windowsize = self.window.get_size() if self.windowsize[1] <= 300: self.window.resize(self.windowsize[0], self.windowsize[1]+30) while (self.window.configure_request_count == 0): return True else: print "done, add stuff to the expanded window." self.button = gtk.Button("Hola") self.vbox.pack_start(self.button, False, False, 0) self.button.show() return False else: self.expandtimeout = gobject.timeout_add(30, self.__expandpreferences)