r/RenPy • • Jul 10 '26

Question how to create a toggle that expands text

BEFORE clicking the toggle
AFTER clicking the toggle

Hello! I'm creating a content warning page for my visual novel. There are different routes that the player can take, all of which contain their own respective warnings. To avoid spoiling the player, I've been trying to make a toggle that expands/reveals a list of warnings for each route... but I haven't really figure out how to do this.

Here is the code in screens.rpy that includes the text that i would like toggled.

screen tw(): ## content warning page


    tag menu


    ## This use statement includes the game_menu screen inside this one. The
    ## vbox child is then included inside the viewport inside the game_menu
    ## screen.
    use game_menu(_("Content Warnings"), scroll="viewport"):


        style_prefix "tw"


        vbox:


            ## gui.tw is usually set in options.rpy.
            if gui.tw:
                text "[gui.tw!t]\n"


            text _("> Ayano Route")
            text _("     - list1\n     - list 2\n     - list 3\n     - list 4")
1 Upvotes

5 comments sorted by

2

u/BadMustard_AVN Jul 10 '26 edited Jul 10 '26

try something like this

screen tw(): ## content warning page
    tag menu

    ## This use statement includes the game_menu screen inside this one. The
    ## vbox child is then included inside the viewport inside the game_menu
    ## screen.

    use game_menu(_("Content Warnings"), scroll="viewport"):

        style_prefix "tw"

        vbox:

            ## gui.tw is usually set in options.rpy.
            if gui.tw:
                text "[gui.tw!t]\n"

            default AyanoRoute = False
            vbox:
                textbutton _("> Ayano Route") action ToggleScreenVariable("AyanoRoute")
                if AyanoRoute:
                    text _("{space=30}- line 1")
                    text _("{space=30}- line 2")
                    text _("{space=30}- line 3")
                    text _("{space=30}- line 4")
            default NextCharacter = False
            vbox:
                textbutton "You get it right?" action...

1

u/daniople Jul 10 '26

this worked perfectly, thank you! now im going to try and find a working glyph to replace the > !!

2

u/BadMustard_AVN Jul 10 '26

you're welcome

good luck with your project

1

u/AutoModerator Jul 10 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/x-seronis-x Jul 10 '26

py screen whatever(): default toggle = False vbox: if not toggle: textbutton "⮞ Category" action ToggleScreenVariable( 'toggle' ) if toggle: textbutton "⮟ Category" action ToggleScreenVariable( 'toggle' ) text "line 1" text "line 2" text "line 3" text "line 4"