2009-12-26 37 views
0

如何使用ScrollableTextLayout的特性通過pyglet顯示和滾動多行字符串(包含「\ n」)?使用pyglet和ScrollableTextLayout渲染和滾動多行段落

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

片段/鏈接被理解。

回答

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值以垂直滾動。

+0

如何將這個畫到屏幕上? – torger 2009-12-27 00:00:08

+0

查看ScrollableTextLayout派生自的TextLayout的文檔。只有8種方法,所以它不應該花費你很長時間。 – Kylotan 2009-12-27 02:46:12