How can I hide the main window titlebar and place a transparent background in kivy framework?

7.7k views Asked by At

I have a small problem and I am working on a small app that uses the python kivy gui framework. All i want is to hide the titlebar of the main window and make the background color transparent. I searched the net intensively but I couldn't find a solution for this.

Does anyone know how to do this?

Thanks

2

There are 2 answers

1
Nykakin On BEST ANSWER

You can disable bar using kivy.config.Config. Set fullscreen as fake:

from kivy.config import Config
Config.set('graphics', 'fullscreen', 'fake')

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        button = Button(text="Exit", size_hint=(None, None))
        button.bind(on_press=exit)
        return button

if __name__ == '__main__':
    MyApp().run()

You can find more configuration options here: http://kivy.org/docs/api-kivy.config.html#available-configuration-tokens For example, to also change position of window:

from kivy.config import Config
Config.set('graphics', 'fullscreen', 'fake')
Config.set('graphics', 'position', 'custom')
Config.set('graphics', 'top', '300')
Config.set('graphics', 'left', '300')

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        button = Button(text="Exit", size_hint=(None, None))
        button.bind(on_press=exit)
        return button

if __name__ == '__main__':
    MyApp().run()

Unfortunately, I don't know whether it's possible to add transparency.

1
cessor On

There is a simpler way:

from kivy.app import App
from kivy.core.window import Window

class MyApp(App):
    def build(self):
        Window.borderless = True

# ...

http://kivy.org/docs/api-kivy.core.window.html#kivy.core.window.WindowBase.borderless