【发布时间】:2020-05-31 16:59:08
【问题描述】:
我正在尝试在我的 python 文件中重新创建下面的 MDCard,我用 kivy 语言编写。虽然我可以在 kivy 语言中很好地做到这一点,但我正在努力用 Python 做到这一点。
kv 文件:
MDCard:
size_hint: 1, None
elevation: 6
oritentation: "horizontal"
spacing: 10
Image:
source: "test_image.jpeg"
allow_stretch: True
keep_ratio: False
size_hint_x: 0.5
BoxLayout:
orientation: "vertical"
BoxLayout:
MDLabel:
text: "Test"
MDLabel:
text: "Test text"
MDLabel:
text: "Longer text here to test wrap around of MDLabel"
py 文件:
md_card = MDCard(size_hint=(1,None), elevation=6, spacing=10,
Image(source="test_image.jpeg", allow_stretch=True, keep_ratio=False, size_hint_x=0.5),
BoxLayout(orientation="vertical", BoxLayout(MDLabel(text="Test"), MDLabel(text="Test text")),
MDLabel(text="Longer text here to test wrap around of MDLabel")))
目前,使用 py 文件我得到一个 SyntaxError:
Image(source="test_image.jpeg", allow_stretch=True, keep_ratio=False, size_hint_x=0.5),
^
SyntaxError: positional argument follows keyword argument
【问题讨论】:
标签: python kivy kivy-language