【问题标题】:Render and scroll through multiline paragraphs using pyglet and ScrollableTextLayout使用 pyglet 和 ScrollableTextLayout 渲染和滚动多行段落
【发布时间】:2009-12-26 11:16:21
【问题描述】:

如何利用 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."

感谢片段/链接。

【问题讨论】:

    标签: python scroll multiline pyglet


    【解决方案1】:

    你创建一个这样的:

    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 值来垂直滚动。

    【讨论】:

    • 如何将其绘制到屏幕上?
    • 查看 ScrollableTextLayout 派生自 TextLayout 的文档。只有 8 种方法,所以应该不会花很长时间。
    猜你喜欢
    • 1970-01-01
    • 2016-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 2013-06-18
    相关资源
    最近更新 更多