It works!! Your 'something like' was pretty close (missed by one character), the keyword for the document style justification is just 'align' like: label.document.set_style(0, len(label.text), dict(align='center')) I'm glad I could help. I'm also glad I can use text.Label instead of font.Text, so I can batch it with other stuff, and I can do so much more with it in terms of styling. Thanks so much, Thomas
On 25 mar, 19:54, "Alex Holkner" <[EMAIL PROTECTED]> wrote: > On 3/26/08, Thomas Woelz <[EMAIL PROTECTED]> wrote: > > > > > Hi > > > I was using the font.Text, and switched to text.Label, but I noticed > > one problem. When the text is not multiline, the text correctly > > centers, but the multiline text doesn't. The halign='center' property > > is still useful to center the content (even if left justified) on the > > screen when text is placed with x, y in the middle of the screen and > > width is smaller than window width. > > The meaning of halign has changed between Text and Label. In Label, > the halign always specifies the anchor position on the label (either > left edge, right edge, or center), and the x coordinate gives the > position of the anchor in the window. In Text the meanings of both of > these properties were overloaded depending on whether or not width was > set. > > To center a label in a window requires you to update it's x position > in the window resize handler (whereas with Text this wasn't > necessarily needed). > > > Another quirk about the Label instantiation is that you can't set > > multiline=True when the label is created because the __init__ method > > doesn't provide a width argument and it throws an error without it. So > > Thanks, I'll look into that (probably by adding a width argument to > the constructor). > > > I have to create the Label, then set the witdth and then the multiline > > attribute is set to True. The resulting multiline text area is > > centered on the screen but it is left justified. > > > Is there a way to change the justification of a multiline Label? > > Something like > > label.document.set_style(0, len(label.text), dict(halign='center')) > > (that is, set the halign style on the document). Apparently I forgot > to add more usable public interfaces for this to Label, so I'll look > into this soon. > > Thanks for the feedback > Alex. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
