问题描述
我希望有一个带有黑色按钮和标签以及白色文本的应用程序,因此,我想有一个空格将这些小部件分隔开.我想为了做到这一点,有必要将背景从默认颜色(黑色)转换为白色.做到这一点的最佳方法是什么?谢谢!
I'd like to have an app with black buttons and labels, and with white text, and thus, would like to have white space separating these widgets. I suppose that in order to do so, it would be necessary to convert the background from the default color, which is black, to white. What is the best way of accomplishing this? Thank you!
推荐答案
一种简单的方法是在根窗口小部件后面简单地绘制一个大的白色矩形.例如,您可以使用kivy语言
A simple way is to simply draw a big white rectangle behind your root widget. For instance, in kivy language you could do
<YourRootWidget>:
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
我想您实际上还可以直接设置kivy清除窗口背景的颜色,该颜色显示为Window.clearcolor
.您可以使用
I think you can also actually directly set the colour that kivy clears the window background with, which is exposed as Window.clearcolor
. You would do this with
from kivy.core.window import Window
Window.clearcolor = (1, 1, 1, 1)
您可能需要将此内容放在应用程序中的其他任何内容之前,因为如果在创建窗口之后运行它不会影响任何操作.
You would probably need to put this before anything else in your app, as it won't affect anything if run after the window has been created.
这篇关于猕猴桃:将背景颜色更改为白色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!