Mohammed Baashar
Mohammed Baashar

Reputation: 557

kivy:button background_color never change

I'm using 'kivy' to design my GUI, but I can't change the color of buttons !

The documentation is quite bold about this; 1)Set .background_normal to "" 2)Set .background_color as a list property like [x,x,x,x]

But I have tried this and it doesn't work

            self.cam1_btn.disabled=False
            self.cam1_btn.background_normal= ''
            self.cam1_btn.background_color=[0/255, 230/255, 64/255, 1]

I also divided the R,G,B values on 255 to get a ratio.

The result is a colorless white button.

How can I overcome this problem?

documentation: https://kivy.org/doc/stable/api-kivy.uix.button.html

platform: Windows OS

Upvotes: 0

Views: 99

Answers (1)

user13622589
user13622589

Reputation:

You can define the button and change the background color like this:

self.cam1_btn = Button(text="Press me",background_color =(.3, .6, .7, 1))

Also, if you want to use RGB colors, you can divide them into 255 and use them in this syntax. for example if you want to use (0,230,64) you should change it to =>

background_color =(.0, .9, .25, 1)

Upvotes: 1

Related Questions