Ren'Py Choice button text allignment and wrapping.

Alfius

Engaged Member
Modder
Sep 30, 2017
2,223
4,611
So I have a question around Choice button wrapping and alignment.

So I'm busy re-designing my UI and want to move the choice buttons complete out of the way.

The problem I ran into is the way that Renpy does the text wrapping. See the image below. I was expecting the work more or less like the red block on the right (Like word), but instead the wrapping put almost every word on it's own line. Needless to say, this will not work for me. :)

Am I doing something wrong or is that just how Renpy does the Choice button wrapping and alignment?

I'm still a beginner Renpy /Python coder.

Example.png

Here is how it is currently set.

Code:
define gui.choice_button_width = 350 #960
define gui.choice_button_height = None
define gui.choice_button_tile = False
define gui.choice_button_borders = Borders(125, 7, 125, 7)
define gui.choice_button_text_font = gui.text_font
define gui.choice_button_text_size = gui.text_size
define gui.choice_button_text_xalign = 0.5


    style choice_vbox:  
        xalign 0.05
        xpos 10
        ypos 260
        yanchor 0.05
        spacing gui.choice_spacing


    style choice_button_text:
        idle_color "#9933ff"
        hover_color "#c996fc"
        insensitive_color "#808080"
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,269
The problem I ran into is the way that Renpy does the text wrapping.
No, the problem you ran into is the padding.


define gui.choice_button_width = 350 #960
[...]
define gui.choice_button_borders = Borders(125, 7, 125, 7)
]

You're asking Ren'py to have 350 pixels large buttons that will have a padding of 125 pixels on both sides. Said otherwise, you're letting 100 pixels by line of text, and obviously you can't fit many words in such place, especially with a size font at 33.
 
  • Like
Reactions: Alfius

Alfius

Engaged Member
Modder
Sep 30, 2017
2,223
4,611
No, the problem you ran into is the padding.


]

You're asking Ren'py to have 350 pixels large buttons that will have a padding of 125 pixels on both sides. Said otherwise, you're letting 100 pixels by line of text, and obviously you can't fit many words in such place, especially with a size font at 33.
*Shakes my head in shame.*

Thanks...will test this afternoon.


Works perfectly Thanks
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,269
Thanks...will test this afternoon.
Be careful, the default padding isn't really bigger, and the choice buttons inherit from the default buttons, that can have a padding by themselves.
Therefore, instead of removing, define gui.choice_button_borders = Borders(125, 7, 125, 7), it's probably better to replace it by something like define gui.choice_button_borders = Borders(10, 7, 10, 7). It would let way more place to your text, while ensuring that you'll not run into a padding defined somewhere else.
 
  • Like
Reactions: Alfius

Alfius

Engaged Member
Modder
Sep 30, 2017
2,223
4,611
Be careful, the default padding isn't really bigger, and the choice buttons inherit from the default buttons, that can have a padding by themselves.
Therefore, instead of removing, define gui.choice_button_borders = Borders(125, 7, 125, 7), it's probably better to replace it by something like define gui.choice_button_borders = Borders(10, 7, 10, 7). It would let way more place to your text, while ensuring that you'll not run into a padding defined somewhere else.
Working 100%
 
  • Like
Reactions: Phlexxx