Align columns in a 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
newbiemate
Regular
Posts: 85
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Align columns in a vpgrid?

#1 Post by newbiemate »

I want to display a row of information, but because each column in my rows have a different width, it messes up the alignment when I stack my rows together.

Here is an example:

Code: Select all

    vpgrid:
        ypos 150
        xalign 0.5
        xsize 1000
        cols 1
        spacing 3
        draggable True
        mousewheel True
        scrollbars "vertical"
        side_xalign 1.0

        hbox:
            xysize (800, 50)
            text "hello"
            text "i am a test"
            text "of alignments"
            textbutton "!!" action NullAction()        
            
        hbox:
            xysize (800, 50)
            text "one"
            text "i am a test"
            text "of alignments"
            textbutton "!!" action NullAction()        

        hbox:
            xysize (800, 50)
            text "longer column"
            text "i am a test"
            text "of alignments"
            textbutton "!!" action NullAction()   


The result looks like:

Code: Select all

hello     i am a test     of alignments     !!
one     i am a test     of alignments     !!
longer column     i am a test     of alignments     !!


How can I make sure the columns are all aligned cleanly within my vpgrid?

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Align columns in a vpgrid?

#2 Post by gas »

Each cell of the hboxes have a variable xsize if you don't specify it.
You should use a style prefix and determine a fixed xsize for text and textbuttons.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Align columns in a vpgrid?

#3 Post by trooper6 »

One thing, you are doing a grid...but you have only one column in your grid. So I'd say add columns. Also note that the size of each cell will be the size of the first cell, so you'll want to set the text_width in the first cell to be as wide as you want all the cells to be. Check this out:

Code: Select all

screen testgrid():
    vpgrid:
        ypos 150
        xalign 0.5
        cols 4
        yspacing 10
        draggable True
        mousewheel True
        scrollbars "vertical"

        # Since we have scrollbars, we have to position the side, rather
        # than the vpgrid proper.
        side_xalign 0.5

        text "hello" min_width 200
        text "i am a test"
        text "of alignments"
        textbutton "!!" action NullAction()

        text "one"
        text "i am a test"
        text "of alignments"
        textbutton "!!" action NullAction()

        text "longer column"
        text "i am a test"
        text "of alignments"
        textbutton "!!" action NullAction()



label start:
    #scene bg_bedroom
    show screen testgrid()

    "Adjust your min_width as you see fit."
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

newbiemate
Regular
Posts: 85
Joined: Tue Dec 19, 2017 1:36 pm
Contact:

Re: Align columns in a vpgrid?

#4 Post by newbiemate »

@trooper6 What is the width property of an "add <image>", if the first column is to be a picture instead of text?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Align columns in a vpgrid?

#5 Post by trooper6 »

The only thing you have to make sure is that the first cell is the size you want all the other cells to be, then you don't need to do anything. So just make sure the picture is the size you want all the cells to be then you don't have to do anything more.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]