import pango, gtk

if __name__ == "__main__":
    w = gtk.Window()
    w.set_default_size(300, 50)
    statusbar = gtk.Label("Should be right-aligned")
    statusbar.set_alignment(1.0, 0.5)
    print "Width before ellipsizing", statusbar.get_layout().get_width()
    statusbar.set_ellipsize(pango.ELLIPSIZE_START)
    print "Width after ellipsizing", statusbar.get_layout().get_width()
    w.add(statusbar)
    w.show_all()
    print "Width after showing", statusbar.get_layout().get_width()
    statusbar.get_layout().set_width(-1)
    print "Width after fixing", statusbar.get_layout().get_width()
    gtk.main()
