[solved] Spacing problem in a hbox

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
thorskin
Newbie
Posts: 5
Joined: Sat Oct 15, 2022 9:13 pm
Contact:

[solved] Spacing problem in a hbox

#1 Post by thorskin » Wed Oct 19, 2022 7:52 am

I have defined a hbox like this :

Code: Select all

   hbox :
      ypos 0
      ysize 200
      xpos 1100
      xsize 800
      box_reverse True
      spacing 10
with a variable number of imagebuttons all of the same size.
The buttons are displayed starting from the right as intended but with a variable spacing to use the full width of the hbox
I want them to have the same spacing whatever the number of buttons (in the limit of the width) justified to the right
How can I force the hbox to use the spacing I specified?
Last edited by thorskin on Wed Oct 19, 2022 1:34 pm, edited 1 time in total.

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Spacing problem in a hbox

#2 Post by _ticlock_ » Wed Oct 19, 2022 12:58 pm

thorskin wrote:
Wed Oct 19, 2022 7:52 am
How can I force the hbox to use the spacing I specified?
I believe the spacing is ignored because the hbox width is already specified. I'm not sure if there is a property that can solve it, however, you can add empty fixed element with xfill True to achieve the desired design:

Code: Select all

    hbox :
        ypos 0
        ysize 200
        xpos 1100
        xsize 800
        box_reverse True
        spacing 10
        
        # variable number of imagebuttons here
        
        fixed:
            xfill True

thorskin
Newbie
Posts: 5
Joined: Sat Oct 15, 2022 9:13 pm
Contact:

Re: Spacing problem in a hbox

#3 Post by thorskin » Wed Oct 19, 2022 1:34 pm

Code: Select all

        fixed:
            xfill True
It half worked, correct spacing but I could not have the buttons on the right side of the box.

I have removed the width. You were right when saying that width disabled spacing.
Then I used xanchor 1.0 to position the right side of the hbox

Code: Select all

    hbox :
      ypos 0
      ysize 200
      xanchor 1.0
      xpos 1900
      box_reverse True
      spacing 10
Now it works as intended.
Thanks for the help.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]