Trying to create a new button style

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Aviala
Miko-Class Veteran
Posts: 533
Joined: Tue Sep 03, 2013 8:40 am
Completed: Your Royal Gayness, Love Bug, Lovingly Evil
Organization: Lizard Hazard Games
Tumblr: lizardhazardgames
itch: aviala
Location: Finland
Contact:

Trying to create a new button style

#1 Post by Aviala »

Hello,

I'm trying to create a new style that I could use to display buttons but I can't figure out how to create and use styles properly. I managed to get the style to show.... something. But it's obviously not what I'm looking for (check the attachment).
For some reason, the button doesn't want to "fill out"; it's just a thin line, and the text shows awkwardly on top.

I tried playing with all the properties I could find and making the values bigger and smaller, but couldn't find one to make the button any thicker.
Also, I'd like to just specify that "everything in this vbox should use style x" but that's also a mystery to me.

I already found a workaround (basically just stole the choice screen style code) but it's not ideal and I'd like to learn how to do this so I can utilize styles from now on...

Relevant code below:

Code: Select all

style letter_button:
    #xmaximum 500
    #xminimum 500
    #yminimum 200
    #xpadding 100
    #bottom_margin 20
    #top_padding 120
    #bottom_padding 10
    idle_background Frame("gui/button/choice_idle_background.png", left=50, top=70, right=50, bottom=40)
    hover_background Frame("gui/button/choice_hover_background.png", left=20, top=50, right=50, bottom=40)
    #xmargin 1
    
    #########
#screens
screen chain_letters:
    text "letter text here" style "letter_text1"
        vbox:
            yminimum 200
            xalign 0.5
            yalign 0.9
            textbutton "Come Out to Omar" action Jump("come_out_omar"), Return() style "letter_button"
            textbutton "Don't Come Out to Omar" action Jump("dont_come_out_omar"), Return() style "letter_button"
    
My workaround, if anyone is interested:

Code: Select all

style letter_button is default:
    properties gui.button_properties("choice_button")
I couldn't find any tutorials on creating styles; I tried to read all the renpy documentation about it I could find but it was pretty confusing. If anyone knows any good tutorials on actually creating new styles and using them, I'd appreciate a link! :) I only found tutorials on how to create grids and boxes and so on, but nothing on creating new styles.
Attachments
screenshot0018.png

User avatar
Empish
Veteran
Posts: 221
Joined: Thu Jan 14, 2016 9:52 pm
Projects: Efemural Hearts, It Ends With Graduation
itch: empish
Contact:

Re: Trying to create a new button style

#2 Post by Empish »

https://www.youtube.com/watch?v=SaWkkmU1QLI

In that tutorial and its accompanying part two I spend some time doing boxes and grids, but also talk about styles and what they are and how to make them. At their most basic, styles are just a short-hand way of applying a bunch of properties at once to a particular screen component.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Trying to create a new button style

#3 Post by Remix »

Code: Select all

style letter_button_text:
    yfill True
Might have to add 'yfill=True, yminimum=NN, xminimum=NN ' to your Frames too...
Frameworks & Scriptlets:

User avatar
Soliloquy
Regular
Posts: 73
Joined: Tue Aug 25, 2015 3:42 pm
Location: Mt Holly, NJ
Contact:

Re: Trying to create a new button style

#4 Post by Soliloquy »

There's also this tutorial: viewtopic.php?f=51&t=9812 It's a little old, but it should also help get you on the right track, if videos aren't your thing.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]