我对我的代码有疑问,找不到任何答案,所以我来到这里。有谁知道是否可以在 kivy 中舍入 image 的 edges 以及如何舍入?我不是指对按钮的 edges 进行四舍五入。
我的 image 代码:
Image:
source: 'assets/images/banner/purple.jpeg'
keep_ratio: True
height: 250
width: 350
center_x: root.width / 2
center_y: 575
附言尝试使用边框属性。没有错误,但 image 也没有变化:(
回答1
在这种情况下,最好的解决方案是用椭圆做一个画布:
kivy 文档:https://kivy.org/doc/stable/examples/gen__canvas__circle__py.html
.kv
canvas:
Color:
rgb: 1, 1, 1
Ellipse:
pos: 100, 100
size: 200, 200
source: 'assets/images/banner/purple.jpeg'
angle_start: 0
angle_end: 360
我建议也看看
动态类:https://kivy.org/doc/stable/api-kivy.lang.html
导入、设置和包含:https://kivy.org/doc/stable/guide/lang.html
这将帮助您保持您的主 kv 文件尽可能小。而且你也有变量,例如文本颜色和东西,所以你只需要在一个地方改变。
希望能帮助到你