我可以用Kivy设计一个像图中这样的按钮吗?
我需要按钮有白色背景,左边有一张图片。还想要左边有个箭头标记,就像图片里那样。我还想让按钮的 corners(角)是圆的。这些要求在 Kivy 里能实现吗?如果可以的话,我该怎么做呢?给我个例子或者什么的!谢谢!

1 个回答
2
以上这些事情在Kivy中可能实现吗?
答案很简单,就是“可以”。你有没有具体的情况让你感到困惑呢?
你只需要创建自己的小部件规则,按照你想要的方式来显示内容。它可能一开始看起来像这样:
<YourRule@BoxLayout>:
text: 'something' # define a property to hold the button text,
# could also be done in python
Image:
size_hint_x: None
width: self.height # make it square
source: 'whatever'
Label:
text_size: self.size # the text wrapping bounds
text: root.text
halign: 'left'
Image:
size_hint_x: None
width: dp(10)
source: 'right_arrow.png' # assuming you have a picture of the button arrow
# you could also draw one manually with kivy canvas instructions