After further investigation, I've discovered the valign and view_y attributes.
With valign = "bottom", it appears to work correctly initially, and
almost works correctly whenever y is reset, but is completely ignored
when insert_text is called.
view_y seems to be completely ignored at all times.
Here's the code to duplicate the problem. I drew a box around the ITL
this time so it's easier to see the problem.
This code OUGHT to put some lines at the top of the box, and then the
new lines should flow down and the text should never scroll. You
should be able to drag the box around without the content changing
position with respect to the border.
What ACTUALLY happens is that the first line flows down from the
bottom of the box right on through the box, and whenever you drag it,
the content warps up into the box + a blank line. Weird.
import pyglet
from pyglet import font
from pyglet import window
from pyglet.gl import *
win = window.Window()
ft = font.load('Arial', 36)
incr_layout = pyglet.text.layout.IncrementalTextLayout(
pyglet.text.document.UnformattedDocument("initial text"),
dpi=72,
multiline=True,
width=400,
height=300)
# Works for initial y and when y is reset, NOT for when text is added
with insert_text
incr_layout.valign = "bottom"
# Doesn't affect anything at all that I can see
incr_layout.view_y = 0
incr_layout.x = 100
incr_layout.y = 100
global count
count = 0
def update():
global count
incr_layout.begin_update()
if count % 100 == 0:
incr_layout.document.insert_text(len(incr_layout.document.text),
"%d\n" % count)
incr_layout.document.set_style(0, len(incr_layout.document.text),
{'color': (255, 255, 255, 255)})
incr_layout.end_update()
count += 1
def on_mouse_drag(x, y, dx, dy, button, modifiers):
incr_layout.x += int(dx)
incr_layout.y += int(dy)
win.on_mouse_drag = on_mouse_drag
while not win.has_exit:
win.dispatch_events()
update()
win.clear()
incr_layout.draw()
glBegin(GL_LINE_LOOP);
glVertex2f(incr_layout.x, incr_layout.y);
glVertex2f(incr_layout.x+incr_layout.width, incr_layout.y);
glVertex2f(incr_layout.x+incr_layout.width,
incr_layout.y+incr_layout.height);
glVertex2f(incr_layout.x, incr_layout.y+incr_layout.height);
glEnd();
win.flip()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---