Page 1 of 1

[SOLVED] Style Not Being Applied to Text Buttons

Posted: Sun Jan 21, 2024 4:30 am
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 

Re: Style Not Being Applied to Text Buttons

Posted: Sun Jan 21, 2024 6:44 am
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.

Re: Style Not Being Applied to Text Buttons

Posted: Sun Jan 21, 2024 7:58 am
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