multiline gtk.Label ignores xalign=0.5
Question: A gtk.Label can't be aligned in center when line-wrap is turned on. Example
code:

    
    
    import pygtk
    pygtk.require('2.0')
    import gtk
    
    class testwin(gtk.Window):
       def __init__(self):
          gtk.Window.__init__(self)
          width,height = 300,300
          self.set_size_request(width,height)
          self.set_position(gtk.WIN_POS_CENTER)
          self.set_title("test window")
    
          label = gtk.Label("test text")
          label.set_line_wrap(True)
          label.set_justify(gtk.JUSTIFY_CENTER)
          label.set_alignment(0.5,0.5)
          label.connect("size-allocate",lambda l,s: l.set_size_request(s.width-1, -1))
    
          self.add(label)
          self.connect("destroy", gtk.main_quit)
          self.show_all()
    
    testwin()
    gtk.main()
    

It looks like this, that means, it's aligned left: <http://m45.img-
up.net/?up=pic122x97.png>

If you comment out line 14 (set_line_wrap) everything is perfectly fine:
<http://o54.img-up.net/?up=pic2y00p9.png>

Please note that yalign works fine. So it seems like the first argument in the
gtk.Misc.set_alignment-function has no effect when line wrap is turned on.

Using Fedora 16, 64bit, gtk 3.2.4, pygtk 2.24.0, python 2.7.2

Question: Is this intended or a bug? How is it supposed to be made or is a
workaround available?


Answer: This isn't really an answer, but it doesn't fit in a comment.

I'm going to guess this is a bug. When I convert your code to run on
[PyGObject](https://live.gnome.org/PyGObject) (PyGTK's successor), it works as
you'd expect.

    
    
    from gi.repository import Gtk
    
    class testwin(Gtk.Window):
       def __init__(self):
          Gtk.Window.__init__(self)
          width,height = 300,300
          self.set_size_request(width,height)
          self.set_position(Gtk.WindowPosition.CENTER)
          self.set_title("test window")
    
          label = Gtk.Label("test text")
          label.set_line_wrap(True)
          label.set_justify(Gtk.Justification.CENTER)
          label.set_alignment(0.5,0.5)
          label.connect("size-allocate",lambda l,s: l.set_size_request(s.width-1, -1))
    
          self.add(label)
          self.connect("destroy", Gtk.main_quit)
          self.show_all()
    
    testwin()
    Gtk.main()
    

Of course, if you're stuck on PyGTK and you can't switch over to PyGObject
right away, then this answer doesn't solve your problem.

