#!/usr/bin/python
from gi.repository import Gtk

POSITION = 250

class MyWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Hello World")
        self.maximize()
        self.connect("configure-event", self.configureCb)
        self.vpaned = Gtk.VPaned()
        self.vpaned.connect("notify::position", self.positionCb)
        self.vpaned.set_position(POSITION)
        self.add(self.vpaned)
        print("Packing widgets")
        label1 = Gtk.Label("LABEL")
        self.vpaned.pack1(label1, resize=True, shrink=False)
        button2 = Gtk.Button(label="BUTTON")
        self.vpaned.pack2(button2, resize=True, shrink=False)
        print("Packing done, showing UI")
        self.show_all()
        print("Init done, UI shown")
        self.vpaned.set_position(POSITION)  # Just in case...

    def positionCb(self, unused_widget, unused_param):
        print("Pane position set to " + str(self.vpaned.get_position()))

    def configureCb(self, unused_widget, event):
        """
        Handle the main window being moved, resized or maximized
        """
        print("Window configured to %s x %s" % (event.width, event.height))
        self.vpaned.set_position(POSITION)  # How could this possibly fail?

    def last_ditch_effort(self):
        print("Why won't you listen to my position advice?")
        self.vpaned.set_position(POSITION)

win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.last_ditch_effort()
Gtk.main()
