How to make textbuttons scrollable in viewport [SOLVED]

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
User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

How to make textbuttons scrollable in viewport [SOLVED]

#1 Post by Luxliev »

How can I make textbuttons scrollable? Text works fine but when I use textbuttons nothing moves.

Code: Select all

screen ui_inv:
    default equipment_counter = 0
    add "cs_bckg.png"
    
    textbutton "Close":
        xalign 1.0
        action Hide('ui_inv')

    vbox:
        area (800, 100, 430, 300)

        viewport id "vp_equipment":
            mousewheel True
            draggable True
            for equipment in party.inv:
                textbutton "[equipment.custom_name]":
                    ypos 30 * equipment_counter
                    action NullAction()
                $ equipment_counter += 1

        vbar value YScrollValue("vp_equipment")

init python:
    class Eq:
        def __init__(self, name):
            self.name = name
            self.custom_name = name
    
    Dirk = Eq("Dirk")
    Dagger = Eq("Dagger")
    Mace = Eq("Mace")        

    class PaD:
            def __init__(self):
                self.inv = []

            def add_equipment(self, *args):
                for element in args:
                    self.inv.append(element)
    
    party = PaD()
    party.add_equipment(Dirk, Dagger, Mace, Dirk, Dagger, Mace, Dirk, Dagger, Mace, Dirk, Dagger, Mace, Dirk, Dagger, Mace, Dirk, Dagger, Mace, Dirk, Dagger, Mace)
    


label start:
    show screen ui_inv
    "Hello, world."

    return
Last edited by Luxliev on Thu Jul 27, 2017 6:01 am, edited 2 times in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: How to make textbuttons scrollable in viewport

#2 Post by Milkymalk »

Put it in a vbox (also note the scrollbars I added):

Code: Select all

        viewport id "vp_equipment":
            mousewheel True
            draggable True
            scrollbars "vertical"
            vbox:
                for equipment in party.inv:
                    textbutton "[equipment.custom_name]":
                        action NullAction()
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: How to make textbuttons scrollable in viewport

#3 Post by Luxliev »

Works great. Thanks for help
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

Post Reply

Who is online

Users browsing this forum: No registered users