我有一个kivy应用程序,我可以使用
Window.clearcolor
在python文件中,如中所建议
kivy: change background color to white
。然后我添加了一个选项卡式面板,使背景恢复为黑色。
我试图使用
canvas
和
canvas.before
和
background_color
使其恢复为白色,但仍呈现黑色(或者更确切地说是深灰色)。
可复制玩具示例
import kivy
from kivy.lang import Builder
from kivy.core.window import Window
kivy.require('1.1.0')
from kivy.app import App
presentation = Builder.load_file("works.kv")
class TestApp(App):
def build(self):
Window.clearcolor = (1, 1, 1, 1)
return presentation
if __name__ == '__main__':
TestApp().run()
使用kv文件:
#:kivy 1.10.0
GridLayout:
cols: 2
Label:
text:'just to force spacing'
Button:
text: 'Hello World'
但是,当我向kv文件添加选项卡式面板时,如下图所示,背景看起来是黑色的(下面的屏幕截图):
#:kivy 1.10.0
BoxLayout:
TabbedPanel:
do_default_tab: False
background_color: (1, 1, 1, 1)
TabbedPanelItem:
text: 'Main'
GridLayout:
cols: 2
Label:
text:'just to force spacing'
Button:
text: 'Hello World'
TabbedPanelItem:
text: 'Tab 2'
屏幕截图:
添加面板之前:
添加面板后(我希望面板有一个白色背景,在这个玩具示例中,文本是白底白字,但我在我的应用程序中处理过):
尝试
<Main>:
name: 'mscreen'
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
TabbedPanel:
do_default_tab: False
TabbedPanelItem:
text: 'Main'
GridLayout: ...
同样地
<Main>:
name: 'mscreen'
canvas:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
TabbedPanel:
do_default_tab: False
TabbedPanelItem:
text: 'Main'
GridLayout:...
如果我在看书
Kivy's documentation on TabbedPanels
正确地说,我应该能够使用background\u color,但这也不起作用:
TabbedPanel:
do_default_tab: False
TabbedPanelItem:
text: 'Main'
background_color: 1,1,1,1
和
TabbedPanel:
do_default_tab: False
background_color:1,1,1,1
TabbedPanelItem:
text: 'Main'
相关的
:我知道其他人都在与Kivy的背景作斗争。据我所知,我尝试了他们的建议。
不太直接相关: