Page 1 of 1

[SOLVED] How to make a border on a textbutton?

Posted: Sat Jul 09, 2022 1:45 pm
by span4ev
Hi all.

There is a text button, there are styles. But I can't make a border.

Code: Select all

screen statsBtn():

    style_prefix 'statsBTN'

    if stats_btn_visible:

        textbutton ('STATS'):

              
style statsBTN_button:
    margin(10,10)
    background "#dc3f26"
    hover_background "#00a"

style statsBTN_button_text:
    size 20
    color "#fff"
    hover_color "#000"
    
There are very clear and intuitive things like for example: margin, background, color, hover_color , size
But it doesn't work with a border... I saw an example on the internet with "Borders(10,10,10,10) but it doesn't work
I have tried several options: Borders(), borders() and others. And I can't find an example code for overriding styles
If you know examples with code for border styles, I will be very glad if you share it. Because I would like to customize the text button, add rounded corners and other nice things like in CSS (if it's possible in Renpy)

Re: How to make a border on a textbutton?

Posted: Sat Jul 09, 2022 11:42 pm
by Imperf3kt
You would need to place your textbutton inside a frame and apply borders to the frame.

Alternatively, use an imagebutton, and instead of images and use a Text("your text here") displayable as the hover_forground idle_foreground objects

https://www.renpy.org/doc/html/text.htm ... splayables

Re: How to make a border on a textbutton?

Posted: Sun Jul 10, 2022 3:53 am
by span4ev
Imperf3kt wrote:
Sat Jul 09, 2022 11:42 pm
You would need to place your textbutton inside a frame and apply borders to the frame.

Alternatively, use an imagebutton, and instead of images and use a Text("your text here") displayable as the hover_forground idle_foreground objects

https://www.renpy.org/doc/html/text.htm ... splayables
Thanks for the answer. It is very sad that just Border is not applicable to a text button.
But I can't use Borders(40, 40, 40, 40) for a frame...
I applied Borders(40, 40, 40, 40) to the frame style and in the frame itself I get the error. Can you give an example please?

Code: Select all

frame:
        style 'stats_main_frame'
        Borders(40, 40, 40, 40) # ERROR
        
style stats_main_frame:        
	Borders(40, 40, 40, 40) # ERROR


Thanks for the answer.

Re: How to make a border on a textbutton?

Posted: Sun Jul 10, 2022 9:43 pm
by Imperf3kt
I don't have time right now as I am just reading this in passing and don't have time to go through it but the documentation on Frames and Borders includes a few examples that may help.

https://www.renpy.org/doc/html/gui.html#borders
https://www.renpy.org/doc/html/displayables.html#Frame

Alternatively, the tutorial from the launcher might have some info as well. I haven't used it in a long time.


If I remember, when I next have time I'll come back to this post and give you a better answer.

Re: How to make a border on a textbutton?

Posted: Mon Jul 11, 2022 3:20 am
by span4ev
Imperf3kt wrote:
Sun Jul 10, 2022 9:43 pm
I don't have time right now as I am just reading this in passing and don't have time to go through it but the documentation on Frames and Borders includes a few examples that may help.

https://www.renpy.org/doc/html/gui.html#borders
https://www.renpy.org/doc/html/displayables.html#Frame

Alternatively, the tutorial from the launcher might have some info as well. I haven't used it in a long time.


If I remember, when I next have time I'll come back to this post and give you a better answer.
Well thank you. I will wait for your detailed answer. Thanks

Re: How to make a border on a textbutton?

Posted: Mon Jul 11, 2022 3:34 am
by span4ev
Imperf3kt wrote:
Sun Jul 10, 2022 9:43 pm
I don't have time right now as I am just reading this in passing and don't have time to go through it but the documentation on Frames and Borders includes a few examples that may help.

https://www.renpy.org/doc/html/gui.html#borders
https://www.renpy.org/doc/html/displayables.html#Frame

Alternatively, the tutorial from the launcher might have some info as well. I haven't used it in a long time.


If I remember, when I next have time I'll come back to this post and give you a better answer.

Ok, thank you. I will wait for your detailed answer. Thanks

I find it difficult to read the documentation for some reasons:

1. I'm using google translator of the page and therefore all the titles that are not wrapped in the "code" tag are also translated. As a result, I get confused and can no longer see the names of methods, properties, functions, etc...
This is solved by taking each line and translating it manually, but you yourself understand that reading documentation with hundreds of lines becomes difficult and inconvenient. Unfortunately, I did not have the opportunity to learn English... But if there is a code example, then I do not need a translation, but...

2. Often the documentation is just a reminder of how it works: PROPERTY - ITS DESCRIPTION. And there is no code example to understand how to put it into practice...

3. In the documentation I see
gui.button_borders = Borders(10, 10, 10, 10)
but I need an example of how to apply this to the style, because sometimes the syntax is different, and what is written in :

Code: Select all

style "style_name":
....property value
not directly applicable in the object.

So the example code
gui.button_borders = Borders(10, 10, 10, 10

Is useless to me.
I need a syntax example for

Code: Select all

style "style_name":
....property value
So I can't read the documentation on the official site. By the way, this applies not only to Renpy, but also to other engines, such as Pygame.
Therefore, it remains for me to either ask on the site, or experiment on my own, or try to look for articles and guides with sample code.