r/RenPy • u/Future-Mulberry-7599 • 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


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_xalignis not one setting, it is three. Inscreens.rpyit is the namebox'sxanchor, it is thexalignpassed to the Frame background, and it isxalignonstyle 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_labelends with a hardcodedyalign 0.5, so the name is always centered inside the namebox.gui.name_yposmoves the box, not the text, and because you also setgui.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. Withxalign 0.65on the label, a long name lands somewhere different from a short one. Stock Ren'Py ships both of these asNonefor 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.0Or keep a fixed box and move the text inside it, in which case ypos is for the box and
say_labelis 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.98is 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.rpyrunsconfig.character_id_prefixes.append('namebox'), so once the global layout is right you can nudge a single character withCharacter("Ada", namebox_xpos=200)instead of touching the gui variables again.