Render and scroll through multiline paragraphs using pyglet and ScrollableTextLayout
Question
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.
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow