Page 1 of 1

How to make all items in vbox to have same xsize?

Posted: Tue Aug 23, 2016 11:16 am
by Ocelot
I have a vbox, which has a vpgrid. That grid manages own width just fine and I do not want to set it explicitely. After it I have viewport which uses another screen, containing ton of text, so, if I do not set width explicitely, it will atempt to fill rest of the screen.

I want second viewport to have the same width as first one. I could find exact width by trial and error, but I expect size of first vpgrid to change during development and maybe even ingame, so hardcoding width(s) is not something I want to do.

So, is there any way to get width of previous item or solve this problem in some other way?

Fragment of screen code (with almost-correct width set manually):

Code: Select all

vbox:
    spacing 8
    vpgrid:    
        ysize 500
        cols 4
        spacing 4
        mousewheel True
        scrollbars "vertical"
        for item in items:
            textbutton "{size=14}Button{/size}":
                xysize (96, 96) 
                action Return()
        
    viewport:
        mousewheel True
        scrollbars "vertical"
        xsize 400
        use item_info

Re: How to make all items in vbox to have same xsize?

Posted: Tue Aug 23, 2016 6:00 pm
by kivik
Not sure if it's the right answer for precise sizing, but I find that "xfill True" seem to do the job for me.

Re: How to make all items in vbox to have same xsize?

Posted: Wed Aug 24, 2016 10:36 am
by Kia
try: size_group
it is used in main menu and preferences if you want to see how it works

Re: How to make all items in vbox to have same xsize?

Posted: Wed Aug 24, 2016 11:58 am
by Ocelot
Sadly size_group didn't work for me: it seems to expand all widgets width to the width of largest one. I have opposite problem: "text" displayable tries to use as much width as possible before starting to wrap words to the next line. I want to limit it to the width of vpgrid defined before.

Re: How to make all items in vbox to have same xsize?

Posted: Wed Aug 24, 2016 12:02 pm
by Kia
have you tried to put them in a frame and give the frame it's size a percentage of the screen? xsize 0.45

Re: How to make all items in vbox to have same xsize?

Posted: Wed Aug 24, 2016 12:37 pm
by Ocelot
I might not understood your proposal, but the problem is finding exact size. As I said, vpgrid width will change, and I do not want to hardcode sizes. For now I set second viewport size manually by inspecting vpgrid in Displayable Inspector and looking at its size, but I want more robust solution.

I found renpy.get_widget_properties function, which seems to be useful for me, but didn't find any examples on its usage.