[SOLVED] How to remove ghost width from frame in 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
span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

[SOLVED] How to remove ghost width from frame in vpgrid?

#1 Post by span4ev » Sun Jul 10, 2022 9:13 pm

I do so:

Code: Select all

vpgrid:
    cols 2
    rows len(dics) # List length value
    
    for i, k in dics.items(): 
        frame:
            style_prefix 'prefix_stats_only_left_frames'
            text str(i)
        frame:
            style_prefix 'prefix_stats_only_right_frames'
            text str(k)
            
I got a parent frame with one background and two children with a different background, each with the number of rows equal to the length of the list.
I use this approach because I want the result to be a table, but the right side with the values should have a small width, and the left side with the variable names should be wide enough, that is, at least 300 wide.

But I have some extra width here, which is measured as a percentage and which I want to get rid of. I need to be able to define the minimum width myself, and the parent frame adjusts to these dimensions.

XFILL False does not help.

What is this value that affects the size? Where is it? I used SHIFT+i and didn't see anything that would affect it.
How can I set this invisible value to 0, or how can I make a fluid (automatic) width that will adjust to child elements?
2022-07-10_101018.png
2022-07-10_10102222222222222222222222218.png
In the screenshots, the values go in this order:
1. Left frame minwidth
2. Right frame minwidth
3. The xsize of the main frame

Some invisible value of 20-40 pixels affects the situation.
Because when both frames have a minimum width of 60 and the parent frame has a width of 130, the right frame part does not fit in the parent frame. Padding has no effect on this.

As I understand, this phantom width is set not in the number of pixels, but in percentage, because if I put:

300 - for the left frame
100 - for the right frame
and 610 - for the main frame
then some of the content of the right frame will not fit.

That is, in this case (610 - (300+100)) I have an extra 220 pixels.
I counted 220 and not 210, because I took into account the necessary number so that the content on the right side does not crawl out of the parent frame.

If I divide all values ​​by 2:
150 - for the left frame
50 - for the right frame
305 - for the main frame

then the extra size will be 115 pixels (taking into account the required number so that the content on the right side does not crawl out of the frame).

75 - for the left frame
25 - for the right frame
165 - for the main frame

then the extra size will be 65 pixels (taking into account the number needed so that the content of the right side does not crawl out of the frame).

As you can see, this is a percentage of the width, not a specific value...

What should I do? I don't want to use fixed sizes because I think it's bad practice. Perhaps it has something to do with vpgrid?

I was also very surprised that Renpy has a minwidth property, but no maxwidth...
Last edited by span4ev on Sat Oct 15, 2022 5:03 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to remove ghost width from frame in vpgrid?

#2 Post by Imperf3kt » Sun Jul 10, 2022 10:09 pm

I believe the reason there is no maxwidth is because your displayable will fill all available space. If you want a maxwidth, place your displayable in a container and constrain its xsize by either directly sizing the container or giving it an xmaximum.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

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

Re: How to remove ghost width from frame in vpgrid?

#3 Post by philat » Mon Jul 11, 2022 12:37 am

A vpgrid assumes that all children are the same size, the size being taken from the dimensions of the first child. If a vpgrid appears to be rendering incorrectly, please ensure that all children are of the same size. https://www.renpy.org/doc/html/screens. ... rid#vpgrid

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: How to remove ghost width from frame in vpgrid?

#4 Post by span4ev » Mon Jul 11, 2022 3:11 am

Imperf3kt wrote:
Sun Jul 10, 2022 10:09 pm
I believe the reason there is no maxwidth is because your displayable will fill all available space. If you want a maxwidth, place your displayable in a container and constrain its xsize by either directly sizing the container or giving it an xmaximum.
I understand. I realized that I need to stop using vpgrid (which is a pity, because it's a convenient thing).
Thanks for the answer and for "xmaximum" - I didn't know about it. Out of habit, after the CSS, I thought that the opposite of the min width is the max width.

In general, I did this according to the level of nesting

Code: Select all

    frame:
        style 'stats_main_frame'

        vbox:

            for i in range(len(Anna.__dict__)):

                hbox:

                    frame:

                        style_prefix 'stats_child_left_frame'
                        text str(list(Anna.__dict__.keys())[i].title())
                    frame:
                        style_prefix 'stats_child_right_frame'
                        text str(list(Anna.__dict__.values())[i])

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: How to remove ghost width from frame in vpgrid?

#5 Post by span4ev » Mon Jul 11, 2022 3:12 am

philat wrote:
Mon Jul 11, 2022 12:37 am
A vpgrid assumes that all children are the same size, the size being taken from the dimensions of the first child. If a vpgrid appears to be rendering incorrectly, please ensure that all children are of the same size. https://www.renpy.org/doc/html/screens. ... rid#vpgrid
I understand you, thanks for the answer.
I chose not to use the grid

Post Reply

Who is online

Users browsing this forum: No registered users