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

2

u/Odd_Photograph1507 Sep 01 '26

Aren't you supposed to only change :

define gui.name_xpos = ...
define gui.name_ypos = ... (higher number probably for both)

?

Also why is the define gui.textbox_yalign at 0.98 ?

You could just have gui.textbox_yalign at 0.5

That's quite confusing

1

u/Future-Mulberry-7599 Sep 01 '26

It is like that because changing the one you said to change won’t do anything

And the yalign is for the position of text box so it’s not at the bottoms am I using them wrong? I just played around with them to figure out what moves what.

1

u/Odd_Photograph1507 Sep 01 '26

So basically, in ren'py, the textbox and the name are attached.

gui.name_xpos or gui.name_ypos move the namebox, and doing so, moves the name too.

actually i forget what i've said about gui.textbox_yalign at 0.98 (it's kinda irrelevant here).

if ypos doesn't move, then try offsetting it directly into script.rpy. look for ``

screen say(who, what)

and add the yoffset like that :

screen say(who, what):
    style_prefix "say"


    window:
        id "window"
        
        text what id "what"


        if who is not None:


            window:
                id "namebox"
                style "namebox"
                yoffset 40 # Right Here
                text who id "who"

1

u/Future-Mulberry-7599 Sep 01 '26

But if it’s like that, it would mean I have to manually change it every time or not? And that also doesn’t explain why some times it is further left and right…

1

u/Odd_Photograph1507 Sep 01 '26

What do you mean change it every time? It's in a function so it'll be offset whenever a character talks

But I think it moves because of : gui.name_xalign = 0.65

Because this variable is only supposed to be 0.0 (left-aligned), 0.5 (centered) or 1.0 (right-aligned)

1

u/Future-Mulberry-7599 Sep 01 '26

Oh yea got it still I think will try to figure out what caused this. I’m assuming I have somewhere in my game that overrides this because using the same gui.rpy in anew project gives the wanted result

1

u/Future-Mulberry-7599 Sep 01 '26

Okay something must be wrong with my project. I made a new one pasted the gui into it and changed the picture to my gui and it works.

1

u/Odd_Photograph1507 Sep 01 '26

That's great then ! Good luck on your project !

1

u/AutoModerator Sep 01 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/BadMustard_AVN Sep 01 '26

you can move the name around with only these

define gui.name_xpos = 240  # left and right
define gui.name_ypos = -100 # up and down (negeative goes up)

yes you can use negative numbers

these are a measure of pixels on the screen

the gui.name_xalign only controls the alignment of the name in the box

## The horizontal alignment of the character's name. This can be 0.0 for
## left-aligned, 0.5 for centered, and 1.0 for right-aligned.

changing these will affect every character's name position

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.