使用pyglet和ScrollableTextLayout渲染并滚动多行段落

时间:2009-12-26 11:16:21

标签: python scroll multiline pyglet

如何使用ScrollableTextLayout的功能通过pyglet显示和滚动多行字符串(包含“\ n”)?

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

但是我不知道如何使用它。这些文档对我来说并不太清楚。

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."

片段/链接表示赞赏。

1 个答案:

答案 0 :(得分:0)

你创建一个这样的:

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

然后使用view_x和view_y值选择滚动位置。

scroll_area.view_y = 30 # start 30 pixels down

设置view_y的不同值以垂直滚动。