[SOLVED] Style Not Being Applied to Text Buttons

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
fgfg3356
Newbie
Posts: 15
Joined: Fri Jul 02, 2021 5:36 am
Contact:

[SOLVED] Style Not Being Applied to Text Buttons

#1 Post by fgfg3356 »

I am currently working on a project where I aim to implement a scroll bar for choices within a choice screen. To facilitate customization, I have crafted a specific style for the 'textbutton' to adjust attributes such as font size and color. Regrettably, this approach does not appear to be functioning as expected. I would greatly appreciate any insights or suggestions that could help me identify and resolve the underlying issue

Code: Select all

style scrollable_menu_frame:
    background Null()
    xsize 600
    ysize 300

style large_textbutton: 
    font "KoPubDotumLight.ttf"
    color "#FF0000"
    size 20  # Increase font size as needed


screen scrollable_menu(choices):
    frame style "scrollable_menu_frame":
        
        xpos 1100
        ypos 0.2
        viewport:
            id "viewport"
            draggable True
            mousewheel True
            vbox:
                spacing 20
                for choice in choices:
                    textbutton choice[0] action choice[1] style "large_textbutton"
        vbar:
            value YScrollValue("viewport")
            xpos 485 
Last edited by fgfg3356 on Sun Jan 21, 2024 7:59 am, edited 1 time in total.

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Style Not Being Applied to Text Buttons

#2 Post by m_from_space »

fgfg3356 wrote: Sun Jan 21, 2024 4:30 am I would greatly appreciate any insights or suggestions that could help me identify and resolve the underlying issue
Your textbutton uses a style. This style contains keywords like "color" or "font" that are not possible for the textbutton, only for text itself.

Usually you would have to write:

Code: Select all

# text object
text "Hello" color "#f00" size 20

# textbutton object
textbutton "Click me!":
    action NullAction()
    text_color "#f00"
    text_size 20
So what you have to do is:

Code: Select all

style large_textbutton is button
style large_textbutton_text:
    font "KoPubDotumLight.ttf"
    color "#FF0000"
    size 20
    
.... textbutton choice[0] action choice[1] style "large_textbutton"
Within the "large_textbutton" style definition, you can of course include textbutton related style properties.

fgfg3356
Newbie
Posts: 15
Joined: Fri Jul 02, 2021 5:36 am
Contact:

Re: Style Not Being Applied to Text Buttons

#3 Post by fgfg3356 »

m_from_space wrote: Sun Jan 21, 2024 6:44 am
fgfg3356 wrote: Sun Jan 21, 2024 4:30 am I would greatly appreciate any insights or suggestions that could help me identify and resolve the underlying issue
So what you have to do is:

Code: Select all

style large_textbutton is button
style large_textbutton_text:
    font "KoPubDotumLight.ttf"
    color "#FF0000"
    size 20
    
.... textbutton choice[0] action choice[1] style "large_textbutton"
Within the "large_textbutton" style definition, you can of course include textbutton related style properties.
Thanks to you, my work is functioning well! Your assistance has significantly advanced my project. I am deeply grateful for your help and sincerely wish you all the best in your future endeavors. Your support has been invaluable, and I hope that wonderful things come your way

Post Reply

Who is online

Users browsing this forum: Google [Bot]