Page 1 of 1

Viewport questions & help

Posted: Fri Feb 15, 2019 7:31 pm
by renpyhelp
Hi. I have two questions about viewports that I can't quite figure out.

I have a viewport set up right now, and the text goes past the visible barriers that I have set up, but right now is draggable/scrollable. I'd like it to automatically scroll to the bottom whenever I append new text to it. Is that possible? Right now, it appends the text to it, but doesn't display it. The player has to manually scroll downwards to see anything new that is added.

Here is the viewport code I'm using right now:

Code: Select all

frame:
        background "transparent.png"    # or use any semi-transparent image you like

        side "c r":
            area (1015, 162, 1250, 400)

            viewport id "vp":
                draggable True
                mousewheel True
                yinitial 1.0

                vbox:
                    spacing 5
                    for k in viewport_test:
                        text k
Another questions is... is it possible to append new text to the TOP of a viewport, rather than automatically to the bottom? As the viewport gets more text, it's kind of a hassle to see new stuff by scrolling down a decent ways.


Thanks to anyone who helps me out. It would be GREATLY appreciated.

Re: Viewport questions & help

Posted: Fri Feb 15, 2019 8:03 pm
by Imperf3kt
I've no idea how its used as I've not looked into it yet, but Scroll() might be what you need
https://www.renpy.org/doc/html/screen_a ... tml#Scroll

Re: Viewport questions & help

Posted: Fri Feb 15, 2019 11:21 pm
by renpyhelp
It seems to have the right idea in mind, but it's an action. I kind of want it to happen automatically on screen. Unsure how I can action assign Scroll to a displayed viewport on screen automatically

edit: The viewport is within a screen, so hide screen / show screen between the append statement seems to work as a bandaid fix (when using "yinitial 1.0") to have it start from the bottom of the viewport.

Re: Viewport questions & help

Posted: Sat Feb 16, 2019 4:55 am
by Alex
If you need to show new stuff at the top of viewport you have two options: either reverse the order of items in viewport_test list or insert new stuff at the beginning of viewport_test list rather than add it.

https://docs.python.org/2.7/tutorial/da ... structures