how to set my window's background color in kivy?

7,079 views
Skip to first unread message

timger timger

unread,
Sep 15, 2012, 12:48:10 AM9/15/12
to kivy-...@googlegroups.com
i create a kivy app
but always the app's background is black
how to change the app's background


class AppUI(App):
    def build(self):
        self.root = get_main_window()
        return self.root

get_mian_window return a FloatLayout object,

Gabriel Pettier

unread,
Sep 15, 2012, 3:52:56 AM9/15/12
to kivy-...@googlegroups.com

Easiest i can think of:

from kivy.graphics import Color, Rectangle

class AppUI(App):
    def build(self):
        self.root = get_main_window()

        with self.root.canvas:
            Color(rgba=(.5, .5, .5))
            Rectangle(size=self.root.size, pos=self.root.pos)
        return self.root

Should work (untested, i'm on phone)

--
 
 
 

Mathieu Virbel

unread,
Sep 15, 2012, 5:43:56 AM9/15/12
to kivy-...@googlegroups.com
Or you can change the clear_color of the Window:

from kivy.base import EventLoop
EventLoop.window.clear_color = (.5, .5, .5, 1)

2012/9/15 Gabriel Pettier <gabriel...@gmail.com>:
> --
>
>
>

timger™

unread,
Sep 16, 2012, 11:54:40 AM9/16/12
to kivy-...@googlegroups.com


timger™  



On Sat, Sep 15, 2012 at 3:52 PM, Gabriel Pettier <gabriel...@gmail.com> wrote:

Easiest i can think of:

from kivy.graphics import Color, Rectangle

class AppUI(App):
    def build(self):
        self.root = get_main_window()
        with self.root.canvas:
            Color(rgba=(.5, .5, .5))
            Rectangle(size=self.root.size, pos=self.root.pos)
        return self.root

thanks for your reply
it work fine
 

Should work (untested, i'm on phone)

Le 15 sept. 2012 06:48, "timger timger" <yishen...@gmail.com> a écrit :

i create a kivy app
but always the app's background is black
how to change the app's background


class AppUI(App):
    def build(self):
        self.root = get_main_window()
        return self.root

get_mian_window return a FloatLayout object,

--
 
 
 

--
 
 
 

Reply all
Reply to author
Forward
0 new messages