Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>First</strong>, your example depends on an image file and its width <em>(not provided)</em>, which complicated testing slightly.</p> <p><strong>Second</strong>, you are creating an <a href="http://pyglet.org/doc/api/pyglet.text.document.UnformattedDocument-class.html" rel="nofollow">UnformattedDocument</a> by calling <a href="http://pyglet.org/doc/api/pyglet.text-module.html#decode_text" rel="nofollow">pyglet.text.decode_text</a>, and then you repeatedly insert text into the <a href="http://pyglet.org/doc/api/pyglet.text.document.UnformattedDocument-class.html" rel="nofollow">UnformattedDocument</a> explicitly at position 0 (the start) on this line:</p> <pre><code>def update(self, dx): self.doc.insert_text(0, "New line".ljust(40)) </code></pre> <p>If you want the text to appear at the end, as you imply in your graphics, insert it at the end!</p> <pre><code>def update(self, dx): # Fix the implied bug self.doc.insert_text(-1, "New line".ljust(40)) </code></pre> <p><strong>Third</strong>, lets answer your actual stated question. If you read the API documentation for the property <a href="http://pyglet.org/doc/api/pyglet.text.layout.ScrollableTextLayout-class.html#view_y" rel="nofollow">ScrollableTextLayout.view_y</a> you will find that...</p> <blockquote> <p>Values outside of the range [height - content_height, 0] are automatically clipped in range.</p> </blockquote> <p>...so setting view_y to -80 when content_height is 0, results in view_y getting clipped to 0 and then you never try setting view_y again. The solution to your scrolling problem is to set view_y each time that your content height changes. For a simple fix, you could simply set view_y such that the bottom of your content will always be scrolled up to the bottom of your frame:</p> <pre><code>def update(self, dx): # Fix the implied bug self.doc.insert_text(-1, "New line".ljust(40)) # The answer to the stated question self.layout.view_y = -self.layout.content_height </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload