Unexpected line-break in Frame / VPGRID

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
Lucascraft
Newbie
Posts: 19
Joined: Mon Mar 28, 2022 4:19 pm
Contact:

Unexpected line-break in Frame / VPGRID

#1 Post by Lucascraft » Sat May 21, 2022 9:30 pm

Hi,

I'm currently encountering a weird bug in which I'm getting an unexpected line break in a frame that I made that has a vpgrid inside the frame.

The frame is a simple one to display character stat gains.

Here is the image of what I am seeing. You will notice that the on the lines for "Knowledge +1" and "Acrobatics +1", it is dropping the "+1" down to the next line, even though there is plenty of room remaining in the frame. I'm not sure what's going on here.
stat_page_bug.png
stat_page_bug.png (7.63 KiB) Viewed 248 times
And here is my code:

Code: Select all

    $ stat_gains_01 = "Strength +1"
    $ stat_gains_02 = "Wisdom +1"
    $ stat_gains_03 = "Knowledge +1"
    $ stat_gains_04 = "Acrobatics +1"
    $ stat_gains_05 = "Aptitude +1"

Code: Select all

    frame:
        xpos 500
        ypos 500
        area (1, 1, 360, 320)

        vpgrid:
            at topleft
            cols 1
            rows 5
            spacing 10
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_01]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_02]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_03]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_04]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_05]{/size}"
Everything is working except for those two lines and I can't figure out why. . .

I know I can accomplish this same thing with a vbox. I've tested it and it works. But vbox doesn't allow me to set the spacing between lines. That's why I'm using a grid. Because the vpgrid allows me to put extra space between the lines.

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Unexpected line-break in Frame / VPGRID

#2 Post by philat » Sat May 21, 2022 9:54 pm

Frame width and vpgrid width are not necessarily the same. That said, no idea why you think vbox can't use spacing property.

Lucascraft
Newbie
Posts: 19
Joined: Mon Mar 28, 2022 4:19 pm
Contact:

Re: Unexpected line-break in Frame / VPGRID

#3 Post by Lucascraft » Sun May 22, 2022 12:36 am

philat wrote:
Sat May 21, 2022 9:54 pm
Frame width and vpgrid width are not necessarily the same. That said, no idea why you think vbox can't use spacing property.
If there is a way to adjust line spacing with vbox, I don’t know how to do it.

User avatar
m_from_space
Veteran
Posts: 302
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Unexpected line-break in Frame / VPGRID

#4 Post by m_from_space » Sun May 22, 2022 4:07 am

Lucascraft wrote:
Sun May 22, 2022 12:36 am
If there is a way to adjust line spacing with vbox, I don’t know how to do it.
The reason this happens is because what a vpgrid is about: "A vpgrid assumes that all children are the same size, the size being taken from the dimensions of the first child." (https://www.renpy.org/doc/html/screens.html#vpgrid)

I don't know why you use vpgrid here anyway, just use a vbox.

Code: Select all

frame:
	# you should either write
        xpos 500
        ypos 500
        xsize 360
        ysize 320
        
        # or
        area (500, 500, 360, 320)

        vbox:
            spacing 10
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_01]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_02]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_03]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_04]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_05]{/size}"

Lucascraft
Newbie
Posts: 19
Joined: Mon Mar 28, 2022 4:19 pm
Contact:

Re: Unexpected line-break in Frame / VPGRID

#5 Post by Lucascraft » Sun May 22, 2022 7:39 am

m_from_space wrote:
Sun May 22, 2022 4:07 am
Lucascraft wrote:
Sun May 22, 2022 12:36 am
If there is a way to adjust line spacing with vbox, I don’t know how to do it.
The reason this happens is because what a vpgrid is about: "A vpgrid assumes that all children are the same size, the size being taken from the dimensions of the first child." (https://www.renpy.org/doc/html/screens.html#vpgrid)

I don't know why you use vpgrid here anyway, just use a vbox.

Code: Select all

frame:
	# you should either write
        xpos 500
        ypos 500
        xsize 360
        ysize 320
        
        # or
        area (500, 500, 360, 320)

        vbox:
            spacing 10
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_01]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_02]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_03]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_04]{/size}"
            text "{size=-10}{color=#DCDCDC}{b}[stat_gains_05]{/size}"
Oh nice. I didn’t know you could use the spacing command like that with vbox. Like I said above, I got it working with the vbox, I just didn’t know about the spacing.

Thanks for the help!

Post Reply

Who is online

Users browsing this forum: No registered users