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

2024-05-17 23:40:50 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

但是我不知道如何使用它。医生们对我解释的不多。在

一些文字:

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

欢迎使用片段/链接。在


Tags: andtheto字符串crops功能stringis
1条回答
网友
1楼 · 发布于 2024-05-17 23:40:50

你可以这样创建一个:

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

您可以使用view_x和view_y值选择滚动位置。在

^{pr2}$

设置不同的视图值以垂直滚动。在

相关问题 更多 >