WewLad
WewLad

Reputation: 767

Kivy - setting the background color of a button.

I'm trying to set the background color of a button to blue using Kivy. I went to an RGB generation website and copied the values from there for the color I wanted however it doesn't seem to be working. My Kivy code for the button is here:

Button:
        text: 'Calories'
        font_size: 30
        on_release: app.root.current = 'calories'
        background_normal: ' '
        background_color: (51, 23, 186.0, 1)

When I run this the button goes pure white. I am also curious as to how I would get the text to change color.

Upvotes: 0

Views: 4273

Answers (2)

yvs93
yvs93

Reputation: 66

delete background_normal: ' ', just use background_color: (R, G, B, A) pick a color in this tool and divide R, G and B by 100 A=always 1 (transparency), for example if you choose (255, 79, 25, 1) write instead (2.55, 0.79, 0.25, 1).

Upvotes: -1

jhh
jhh

Reputation: 673

Looking at the examples at github it seems the values aren't 0-255 RGB like you might expect but are 0.0-1.1

bubble.background_color = (1, 0, 0, .5) #50% translucent red
background_color: .8, .8, 0, 1

etc.

You'll probably need something like

background_color: .2, .1, .73, 1

Upvotes: 1

Related Questions