(Solved!) Background color on screen hbox

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
morrie
Regular
Posts: 33
Joined: Mon Aug 01, 2016 11:18 am
Tumblr: morrie-games
Contact:

(Solved!) Background color on screen hbox

#1 Post by morrie » Thu Feb 02, 2017 9:00 am

Hi, I searched a lot but can't figure out how this works...... I have this:

Code: Select all

init python:
    style.hbox['StatusBar'].background = "#999"
    style.hbox['StatusBar'].color = "#eee"
    style.hbox['StatusBar'].size = 20
Which affects this screen object:

Code: Select all

        hbox:
            text "Status: [PlayerStatus]" style style.hbox["StatusBar"]
But only the text color and text size are being affected in my game. I want to change the background color of the hbox as well, but it's not getting a background color at all. How can I do that? I'm sorry, I'm still only learning so I don't understand advanced codes and explanations very well.

EDIT: I am now looking at the gui.rpy (I was using an older version of Ren'Py before that didn't have that file) but I don't understand how to change the background color of my hbox:es from there either.

EDIT2: I'm going to keep using the old GUI (where there's no gui.rpy file). I put a "frame" element around my hbox now, and was able to change the background color of the frame. So, right now I can sort of change the background color of the hbox if it's contained inside a frame, but can't I just change the background of the hbox on its own?
Last edited by morrie on Wed Feb 08, 2017 8:11 am, edited 5 times in total.

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

Re: Background color on screen displayables

#2 Post by Imperf3kt » Thu Feb 02, 2017 9:10 am

You're only adjusting the bar itself, what you wanna look at is whatever sets the color of the hbox itself. Are you using the new or old GUI?

I've never bothered trying to change the color of boxes, but I believe the gui.rpy should cover it somewhere
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

User avatar
morrie
Regular
Posts: 33
Joined: Mon Aug 01, 2016 11:18 am
Tumblr: morrie-games
Contact:

Re: Background color on screen displayables

#3 Post by morrie » Thu Feb 02, 2017 9:22 am

Imperf3kt wrote:You're only adjusting the bar itself, what you wanna look at is whatever sets the color of the hbox itself. Are you using the new or old GUI?

I've never bothered trying to change the color of boxes, but I believe the gui.rpy should cover it somewhere
Um... I don't know if it's new or old.... I was using information from this page:
https://www.renpy.org/doc/html/screens.html
I don't have a gui.rpy. Maybe it's time to update my Ren'Py.....

How can I know what sets the color of the hbox?

User avatar
morrie
Regular
Posts: 33
Joined: Mon Aug 01, 2016 11:18 am
Tumblr: morrie-games
Contact:

Re: Background color on screen displayables

#4 Post by morrie » Thu Feb 02, 2017 9:43 am

I downloaded the latest Ren'Py and I guess that means I was using the "old" GUI since I didn't have any of these new GUI settings. I've been using the same program version for like 2 years since I was just playing around with making simple little stories. I'm trying to make a more advanced thing with buttons and stats on the screen now.

I'm confused with all those new GUI things suddenly there, but I'll add my old game code into a new project and try out the "bar" section in the gui.rpy and see if that does what I want. Thanks for the help and I'll come back if it doesn't work!
*perpetual beginner who can't wrap my head around coding....*

User avatar
morrie
Regular
Posts: 33
Joined: Mon Aug 01, 2016 11:18 am
Tumblr: morrie-games
Contact:

Re: Background color on screen hbox

#5 Post by morrie » Thu Feb 02, 2017 10:17 am

I'm really overwhelmed by the gui.rpy and can't figure out how to use that to change the hbox:es in my screen....

I really just want to define individual styles for my screen things (they'll be various kinds of bars/buttons like your health status, how much money you have, etc, and I don't want them to have the same exact style as each other). I don't want all the elements to look the same. I just don't understand how to make the background color change.

EDIT: I get the feeling that it's easier for me to stick with the old version and not use the new GUI, because suddenly I have to change all these images that I don't have an interest in using from the start. I don't really want to sit and make 30 pieces of graphics for buttons..... I prefer defining background and text hex colors for my buttons/bars/other things in the game. I updated my first post with some additional information at the end.
*perpetual beginner who can't wrap my head around coding....*

User avatar
gas
Miko-Class Veteran
Posts: 730
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Background color on screen hbox

#6 Post by gas » Thu Feb 02, 2017 2:34 pm

The problem are not the GUI statements... is that new projects created now are hard coded.
In fact are not "empty", but have a GUI style sheet applied AND worst the screens are hardcoded to work with.
(I'm all against that new approach,is totally user unfriendly).


You don't need it, anyway. GUI doesn't strip out anything of the old code, is far better to use legacy themes (the Ren'Py core is EXACTLY the same).
What you need to understand to solve your problems is the child-parent system of elements.
Hbox take multiple childs, so you can't properly define a background in advance.
While a frame or a window get only one child, so you can define a background.
Of course, putting an hbox inside a frame is a good solution.
Then you can define these properties of that single frame, creating a new style or applying properties directly.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll be not notified about.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
morrie
Regular
Posts: 33
Joined: Mon Aug 01, 2016 11:18 am
Tumblr: morrie-games
Contact:

Re: Background color on screen hbox

#7 Post by morrie » Thu Feb 02, 2017 4:08 pm

gas wrote:The problem are not the GUI statements... is that new projects created now are hard coded.
In fact are not "empty", but have a GUI style sheet applied AND worst the screens are hardcoded to work with.
(I'm all against that new approach,is totally user unfriendly).


You don't need it, anyway. GUI doesn't strip out anything of the old code, is far better to use legacy themes (the Ren'Py core is EXACTLY the same).
What you need to understand to solve your problems is the child-parent system of elements.
Hbox take multiple childs, so you can't properly define a background in advance.
While a frame or a window get only one child, so you can define a background.
Of course, putting an hbox inside a frame is a good solution.
Then you can define these properties of that single frame, creating a new style or applying properties directly.
Yeah, I'll just keep using the old version. I don't want to do extra coding just to change the new default GUI...... coding is hard *sigh* But it's good that there's an option to use the old GUI even in the new version of Ren'Py.

Do you mean that it's basically a good solution to put all of my boxes in different frames to use different background colors?
*perpetual beginner who can't wrap my head around coding....*

User avatar
xavimat
Eileen-Class Veteran
Posts: 1446
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Background color on screen hbox

#8 Post by xavimat » Sun Feb 05, 2017 6:27 pm

morrie wrote:Do you mean that it's basically a good solution to put all of my boxes in different frames to use different background colors?
Yes.
The thing is that boxes have no "background" property, and frames/windows have it.
They lack of other properties, like margin and padding. Frame and window have all of them: https://www.renpy.org/doc/html/style_pr ... properties
My usual solution is to put a box inside a frame using "has". This way, there is no need to extra-indent.
Doc: https://www.renpy.org/doc/html/screens. ... -statement

In fact, boxes are created only to organize vertically or horizontally, and windows and frames can do the other things (colors, backgrounds, margins, paddings...)
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
morrie
Regular
Posts: 33
Joined: Mon Aug 01, 2016 11:18 am
Tumblr: morrie-games
Contact:

Re: Background color on screen hbox

#9 Post by morrie » Wed Feb 08, 2017 8:10 am

xavimat wrote:
morrie wrote:Do you mean that it's basically a good solution to put all of my boxes in different frames to use different background colors?
Yes.
The thing is that boxes have no "background" property, and frames/windows have it.
They lack of other properties, like margin and padding. Frame and window have all of them: https://www.renpy.org/doc/html/style_pr ... properties
My usual solution is to put a box inside a frame using "has". This way, there is no need to extra-indent.
Doc: https://www.renpy.org/doc/html/screens. ... -statement

In fact, boxes are created only to organize vertically or horizontally, and windows and frames can do the other things (colors, backgrounds, margins, paddings...)
Thanks, that helps, I feel like I understand it a lot better now! (Sorry for the late reply, I was busy....)
*perpetual beginner who can't wrap my head around coding....*

Post Reply

Who is online

Users browsing this forum: Google [Bot]