Ren'Py How to replace textbutton for image in main menu

elcapizo

Newbie
Game Developer
Jun 7, 2017
93
173
Hello, i created some nice images for the start, load , preferences etc , but i do not know how to code them and replace the text , im a very begginner but with passion to learn.

Thank you
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
Hello, i created some nice images for the start, load , preferences etc , but i do not know how to code them and replace the text , im a very begginner but with passion to learn.
By customizing the , replacing the with .

Therefore, something like this :
Code:
screen navigation():
[...]
        if main_menu:

            imagebutton:
                auto "myStartBtn_%s.png"
                action Start()

        else:

            imagebutton:
                auto "myHistorytBtn_%s.png"
                action ShowMenu("history")
[...]
 
  • Like
Reactions: Cul and ddeadbeat

elcapizo

Newbie
Game Developer
Jun 7, 2017
93
173
Hello againm it gives me a error , my code is this, i just replaced the start button to test it out, my png file its called start.png
Code:
screen navigation():

    frame:
        background Frame("gui/frame.png", Borders(50,50,50,50))
        xpos 20
        yalign 0.5
        xsize 300
        ysize 600
    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign .5

        spacing gui.navigation_spacing

        if main_menu:


            imagebutton:
                auto "start.png"
                action Start()

        else:

            textbutton _("History") action ShowMenu("history")

            textbutton _("Save") action ShowMenu("save")

        textbutton _("Load") action ShowMenu("load")

        textbutton _("Preferences") action ShowMenu("preferences")
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
Code:
            imagebutton:
                auto "start.png"
When you follow the link I provided, you can read :
"auto
Used to automatically define the images used by this button. This should be a string that contains %s in it. If it is, and one of the image properties is omitted, %s is replaced with the name of that property, and the value is used as the default for that property."

I let you read the rest of the documentation for a better understanding.
 

elcapizo

Newbie
Game Developer
Jun 7, 2017
93
173
it worked thank you very much, and sorry for being so amateur, i really need to take a python course xD
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
it worked thank you very much, and sorry for being so amateur, i really need to take a python course xD
Don't worry.

I may seem a little harsh in my answer, but it wasn't my intent. I was more point the fact that, despite all its flaw, Ren'py's documentation is really helpful, than anything else.
Most of the time the answer is in it, and while searching you generally discover interesting things.
 
  • Like
Reactions: Ryder282

kotte

Member
Feb 11, 2018
182
318
And if you prefer video tutorials, I can highly recommend Elaine's channel on youtube:


She will guide you all the way from how to get started, up to some pretty advanced topics.