如何隐藏主窗口标题栏并在 kivy 框架中放置透明背景?

How can I hide the main window titlebar and place a transparent background in kivy framework?(如何隐藏主窗口标题栏并在 kivy 框架中放置透明背景?)

本文介绍了如何隐藏主窗口标题栏并在 kivy 框架中放置透明背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题,我正在开发一个使用 python kivy gui 框架的小应用程序.我想要的只是隐藏主窗口的标题栏并使背景颜色透明.我在网上搜索了很多,但找不到解决方案.

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.

有人知道怎么做吗?

谢谢

推荐答案

您可以使用 kivy.config.Config 禁用 bar.将fullscreen设置为fake:

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()

您可以在此处找到更多配置选项:http://kivy.org/docs/api-kivy.config.html#available-configuration-tokens 例如,还要改变窗口的位置:

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.

这篇关于如何隐藏主窗口标题栏并在 kivy 框架中放置透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何隐藏主窗口标题栏并在 kivy 框架中放置透明背景?

基础教程推荐