views:

76

answers:

1

How can one display and scroll through a multi-line strings (contain "\n") via pyglet using the features of ScrollableTextLayout?

STL crops what is display, and seems to be the most efficient way to implement scrolling.

However I have no idea as to how to use it. The docs do not elucidate much to me.

SomeText:

string = "Some multiline \n text is contained within this string \n which must be rendered \n such that it is able to be scrolled through."

Snippets/Links are appreciated.

A: 

You create one like this:

scroll_area = pyglet.text.layout.ScrollableTextLayout(my_text, width, height, multiline=True)

And you choose your scroll position with the view_x and view_y values.

scroll_area.view_y = 30 # start 30 pixels down

Set different values of view_y to scroll vertically.

Kylotan
How would one draw this to the screen?
Nazarius Kappertaal
Look at the docs for TextLayout, which ScrollableTextLayout derives from. There are only 8 methods so it shouldn't take you long.
Kylotan