可以在Kivy中的图像圆形边缘吗?
我对我的代码有疑问,找不到任何答案,所以我来了。有人知道是否可以在Kivy中绕过图像的边缘吗?我不是指舍入按钮的边缘。
我的图像代码:
Image:
source: 'assets/images/banner/purple.jpeg'
keep_ratio: True
height: 250
width: 350
center_x: root.width / 2
center_y: 575
PS尝试使用边框属性。没有错误,但图像也没有变化:(
I had a question about my code and couldn't find any answers so I came here. Does anyone know if it is possible to round the edges of an image in kivy and how? I am not referring to rounding a button's edges.
My image code:
Image:
source: 'assets/images/banner/purple.jpeg'
keep_ratio: True
height: 250
width: 350
center_x: root.width / 2
center_y: 575
P.S. Tried using the border property. No errors but no change in the image either :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,最好的解决方案是用椭圆形成画布:
kivy doc:
.kv
我也建议您查看
动态类:
https://kivy.org/doc/doc/stable/stable/api--kivy.lang。 html
导入,设置并包括:
https://kivy.org/doc/doc/stable/guide/guide/guide/lang.htm.html.html
这将帮助您保持主KV文件尽可能小。因此,您也有变量,例如文本颜色和内容,因此您只需要在一个地方进行更改即可。
希望它有帮助
In this case the best solution would be to do a canvas with a Ellipse:
kivy doc:
https://kivy.org/doc/stable/examples/gen__canvas__circle__py.html
.kv
I would suggest also looking at
Dynamic Classes:
https://kivy.org/doc/stable/api-kivy.lang.html
import, set and include :
https://kivy.org/doc/stable/guide/lang.html
this would help you keep your main kv file as small as possible. And also so you have variables for example text colors and stuff so you only need to change in one place.
Hope it helps