[Solved] Adding scrollbar to screen based on iterative size

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
revlith
Newbie
Posts: 3
Joined: Mon Dec 05, 2016 11:03 am
Github: duncanpi
Contact:

[Solved] Adding scrollbar to screen based on iterative size

#1 Post by revlith »

I'm trying to have a scrollbar only added to the choice screen based on if the options are going offscreen.

I've gotten it so that it consistently has a scroll bar if i uncomment the line beneath the viewport, and the counting works. But all my code does right now is move the options to the left without a scrollbar. I can get it to add a scrollbar to the window if the options go offscreen but that's useless. I have no idea why this doesn't work, please help :cry:

Code: Select all

screen choice(items):  
    window:
        style_prefix "choice"
        $ needS = False
        area (350, 100, 1250, 750)
        viewport:
#            scrollbars "vertical"
            vbox:
                spacing 40
                $ count=0
                for i in items:
                    $ count +=1
                    if count >= 9:
                        $ needS = True

                        textbutton i.caption action i.action
                        
                    else:
                        textbutton i.caption action i.action

            if needS:
                scrollbars "vertical"
                
Last edited by revlith on Mon Dec 05, 2016 8:39 pm, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Adding a scrollbar to the choice menu based on length

#2 Post by xela »

Try something along the lines of:

Code: Select all

screen choice(items): 
    window:
        style_prefix "choice"
        area (350, 100, 1250, 750)
        viewport:
            if len(items) >= 9:
                scrollbars "vertical"
            vbox:
                spacing 40
                for i in items:
                    textbutton i.caption action i.action
Like what we're doing? Support us at:
Image

revlith
Newbie
Posts: 3
Joined: Mon Dec 05, 2016 11:03 am
Github: duncanpi
Contact:

Re: Adding a scrollbar to the choice menu based on length

#3 Post by revlith »

That works! and it'd shown me a way neater way of approaching things, cheers!

User avatar
scorlight
Regular
Posts: 67
Joined: Fri Sep 13, 2013 7:02 am
Contact:

Re: [Solved] Adding scrollbar to screen based on iterative size

#4 Post by scorlight »

OMG THANK YOU SO MUCH!!! I was desperate with my codes until I found this magic!!! Thank you!
Artist for rent, see my art here: http://scorlight.deviantart.com/gallery/

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]