要求:
我试图熟悉KiyvMD,预期的UI布局的第一行是一个工具栏,其后是MDAccordion,它带有两个不同的子项[MDAccordionSubItem]。下面是代码片段
问题 运行此代码时,出现错误“ kivy.lang.parser.ParserException:[文件位置]
25:标签: 26: 27:specific_text_color:1、1、1、1 28:MDAccordionItem: 29:标题:“ HOME”
我看到错误是在第27行引起的,我只是不明白为什么?在4个空格后声明第28行的内容仍然会引发相同的错误。欢迎您提供反馈意见:)
#:import Toolbar kivymd.toolbar.Toolbar
#:import get_color_from_hex kivy.utils.get_color_from_hex
#:import colors kivymd.color_definitions.colors
<Manager>:
id: screen_manager
screen_accordion: screen_accordion_id
ScreenAccordion:
id: screen_accordion_id
name: 'screenAccordion'
manager: screen_manager
<ScreenAccordion>:
BoxLayout:
orientation: 'vertical'
Toolbar:
id: toolbar
title: 'Accordion Test Screen'
background_color: app.theme_cls.primary_dark
left_action_items: [['menu', lambda x: app.nav_drawer.toggle()]]
Label:
# ------------Display the KivyMD Accordion here, below the Toolbar-----------------
specific_text_color: 1,1,1,1
MDAccordionItem:
title: "HOME"
icon: 'key'
MDAccordionSubItem:
GridLayout:
rows:2
BoxLayout:
size_hint: .5, None
height: 420
pos_hint: {'center_x': 1}
padding: 10
spacing: 3
orientation: 'vertical'
Label:
text: "EMPLOYEE ID"
size_hint: (.5, None)
height: 30
color: 1,1,1,1
TextInput:
id: sl_no
size_hint: (.5, None)
height: 30
multiline: False
MDLabel:
text: "EMPLOYEE NAME"
size_hint: (.5, None)
height: 30
color: 1,1,1,1
TextInput:
id: exp_name
size_hint: (.5, None)
height: 30
multiline: False
MDLabel:
text: "DATE OF JOINING" #DATE
size_hint: (.5, None)
height: 30
color: 1,1,1,1
TextInput:
id: date
size_hint: (.5, None)
height: 30
multiline: False
MDLabel:
text: "DESIGNATION"
size_hint: (.5, None)
height: 30
color: 1,1,1,1
TextInput:
id: nucleicacid_type
size_hint: (.5, None)
height: 30
multiline: False
MDAccordionItem:
title: "EMPLOYEE DETAILS"
icon: 'file-document'
MDAccordionSubItem:
BoxLayout:
TabbedPanel:
do_default_tab: False
tab_height:40
tab_width: self.parent.width / 2
TabbedPanelItem:
text: "TAB 1"
TextInput:
id: notes
TabbedPanelItem:
text: "TAB 2"
GridLayout:
rows: 4
BoxLayout:
orientation: "horizontal"
TabbedPanel:
do_default_tab: False
tab_height:20
tab_width: self.parent.width / 4
TabbedPanelItem:
text: "IMAGE 1"
Image:
id: na_one_image
allow_stretch: True
keep_ratio: True
TabbedPanelItem:
text: "IMAGE 2"
Image:
id: na_two_image
allow_stretch: True
keep_ratio: True