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

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
span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

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

#1 Post by span4ev » Sat Jul 09, 2022 1:45 pm

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)
Last edited by span4ev on Sat Oct 15, 2022 5:03 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to make a border on a textbutton?

#2 Post by Imperf3kt » 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
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: How to make a border on a textbutton?

#3 Post by span4ev » Sun Jul 10, 2022 3:53 am

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.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to make a border on a textbutton?

#4 Post by Imperf3kt » 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.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: How to make a border on a textbutton?

#5 Post by span4ev » Mon Jul 11, 2022 3:20 am

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

span4ev
Regular
Posts: 77
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Re: How to make a border on a textbutton?

#6 Post by span4ev » Mon Jul 11, 2022 3:34 am

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.

Post Reply

Who is online

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