我想更改选项卡上的背景颜色,并更改为默认的灰色,但是我无法找出方法。
我曾尝试定义一个画布,但最终在标签上像彩色图层一样创建了内容,然后我无法读取标签上的文本。
我的.py文件:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class IntroScreen(Screen):
pass
class MainScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
app=Builder.load_file("main.kv")
class mainApp(App):
def build(self):
return app
mainApp().run()
main.kv文件:
#: import FadeTransition kivy.uix.screenmanager.FadeTransition
#: import get_color_from_hex kivy.utils.get_color_from_hex
ScreenManagement:
transition: FadeTransition()
MainScreen:
<MainScreen>:
name: "main_screen"
BoxLayout:
orientation: "horizontal"
height: 30
BoxLayout:
orientation: "horizontal"
TabbedPanel:
do_default_tab: False
tab_width: self.parent.width/2
canvas.before:
Color:
rgb: get_color_from_hex("#ffffff")
Rectangle:
size: self.size
pos: self.pos
TabbedPanelItem:
text: "Tab 1"
color: get_color_from_hex("#ffffff")
markup: True
Label:
text: "contents of tab 1"
color: get_color_from_hex("#000000")
canvas.before:
Color:
rgb: get_color_from_hex("#ffffff")
Rectangle:
size: self.size
pos: self.pos
TabbedPanelItem:
text: "Tab 2"
markup: True
Label:
text: "contents of tab 2"
color: get_color_from_hex("#000000")
canvas.before:
Color:
rgb: get_color_from_hex("#ffffff")
Rectangle:
size: self.size
pos: self.pos