renpy/doc/reference/functions/ui.textbutton - Ren'Py

documentation index ◦ reference manual ◦ function index

# ui.textbutton

Function: | ui.textbutton | (text, clicked=None, text_style='button_text', **properties):

This creates a button that is labelled with some text.

text - The text of this button.

clicked - A function that is called with no arguments when this button is clicked. If it returns a non-None value, then that value is returned from ui.interact(). If this would add new content to the screen, it's best if this is of the form ui.returns(UserFunctionThatDisplaysThings): see examples below.

hovered - A function that is called with no arguments when this button is focused. If it returns a non-None value, then that value is returned from ui.interact().

unhovered - A function that is called with no arguments when the button loses focus.

text_style - The style that is used for button text.

role - The role this button undertakes. This can be the empty string, or "selected_".

Note that code in the clicked, hovered, and unhovered methods is run inside the current interaction. This means that the screen is not cleared while this code is run. Displayables may be added or removed from the current interaction, provided renpy.restart_interaction is called to let Ren'Py know that the interaction has been changed. You should not run code that causes a new interaction from inside these functions, except inside a new context using renpy.call_in_new_context, renpy.invoke_in_new_context, or ui.callsinnewcontext.

## Example

    python:
        while True:
            ui.vbox()
            ui.textbutton("Keep going", clicked=ui.returns(("keep", True)), xminimum=250)
            ui.textbutton("Finish", clicked=ui.returns(("done", True)), xminimum=250)
            ui.close()

            type, value = ui.interact()

            if type == "done":
                break

## See also

- ui.text
- ui.button
- ui.imagebutton
- ui.returns

documentation index ◦ reference manual ◦ function index