I'm assuming the purpose of being able to set a label's height in
pixels is to be able to cut the text off after it reaches a certain
height. If that's not correct, than you should stop me right now and
tell me what it's for.
With the above assumption, I've got two separate issues with text.Label.
1) Label.height does not stop the Label's content from exceeding that height.
2) With "valign='bottom'" with multiline text, AND a content height
larger than the specified Label.height, the top of the text locks to
Label.y + Label.height, and the bottom of the text keeps on flowing
right past Label.y. This breaks both the valign setting (who knows
where the bottom is now?) and the height setting.
I dug into pyglet/text/__init__.py and pyglet/text/layout.py looking
at Label, DocumentLabel, and TextLayout. It appears that the height
parameter is passed all the way down and set correctly, but then I get
a bit lost trying to figure out where (and how) in TextLayout the
height restriction ought to be actually enforced. At least I'm
getting closer to being able to try fixing stuff and submitting
patches instead of just reporting bugs... :-)
I'm trying to implement a little log-viewer that scrolls upward
(latest line on the bottom, text disappears off the top). Here's some
example code the illustrates the above two problems:
#!/usr/bin/env python
import pyglet
from pyglet.gl import *
window = pyglet.window.Window(500, 500)
label = pyglet.text.Label(
"""Press a key to add a line. I'd like the content to 1) stay
inside this box, and 2) always have the latest line at the bottom of
the box with the oldest line 'disappearing' off the top.""",
font_name='Times New Roman',
font_size=12,
x=100, y=100,
dpi=72,
multiline='true',
valign='bottom',
halign='left',
width=300,
height=300)
def draw_square():
glLineWidth(1);
glBegin(GL_LINE_LOOP);
glVertex2f(100, 100);
glVertex2f(400, 100);
glVertex2f(400, 400);
glVertex2f(100, 400);
glEnd();
@window.event
def on_draw():
window.clear()
label.draw()
draw_square()
line_num = 1
@window.event
def on_key_press(symbol, modifier):
global line_num
label.begin_update()
label.text += '\n%d Lorem ipsum dolor sit amet, consectetur
adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna
aliquam. Ut enim ad minim veniam, quis nostrud exerc. Irure dolor in
reprehend incididunt ut labore et dolore magna aliqua.' % line_num
label.end_update()
line_num += 1
pyglet.app.run()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---