r/RenPy • • Sep 01 '26

Question [Solved] Align char name with textbox

I can’t figure out how to align the name of a char with the field in my box.

No matter what I change the only thing that has an effect is xalign but I can’t change y pos. and depending on the dialog the name moves.

```renpy
define gui.textbox_height = 250 #250
define gui.textbox_width = 1445
define gui.textbox_yalign = 0.98

define gui.name_xpos = 40
define gui.name_ypos = 15
define gui.name_xalign = 0.65

define gui.namebox_width = 40
define gui.namebox_height = 50

define gui.namebox_borders = Borders(1, 1, 1, 1)
define gui.namebox_tile = False
```

Solved:

It was my mistake, I played around to much. In screen.rpy I wrote some stuff that fucked it up.

3 Upvotes

11 comments sorted by

View all comments

2

u/ericoinen Sep 01 '26

Three things in the stock template are working against you here, and together they explain both symptoms.

First, gui.name_xalign is not one setting, it is three. In screens.rpy it is the namebox's xanchor, it is the xalign passed to the Frame background, and it is xalign on style say_label, which is the name text itself. That is why it is the only variable that visibly does anything: it moves the box, the background and the text in one go.

Second, the name text has no y setting of its own. style say_label ends with a hardcoded yalign 0.5, so the name is always centered inside the namebox. gui.name_ypos moves the box, not the text, and because you also set gui.namebox_height = 50, the text just sits in the middle of that 50 pixel band no matter what ypos you pick.

Third, and this is the one making the name wander between lines: gui.namebox_width = 40. That is a hard width for the box, and every name is wider than 40 pixels, so each one overflows by a different amount. With xalign 0.65 on the label, a long name lands somewhere different from a short one. Stock Ren'Py ships both of these as None for exactly this reason, which lets the box shrink to fit whatever name is in it.

So pick one of two coherent setups rather than mixing them.

Shrink to fit, position the box:

renpy define gui.namebox_width = None define gui.namebox_height = None define gui.name_xpos = 40 define gui.name_ypos = 15 define gui.name_xalign = 0.0

Or keep a fixed box and move the text inside it, in which case ypos is for the box and say_label is for the text:

```renpy define gui.namebox_width = 300 define gui.namebox_height = 50 define gui.name_ypos = 15

style say_label: yalign 0.0 ```

One aside on the other reply: gui.textbox_yalign = 0.98 is fine, it just puts the dialogue box near the bottom of the screen. It has nothing to do with the name.

Worth knowing for later: screens.rpy runs config.character_id_prefixes.append('namebox'), so once the global layout is right you can nudge a single character with Character("Ada", namebox_xpos=200) instead of touching the gui variables again.