整合 Kivy 标签和图标的最佳方式

Best way to integrate a Kivy label and icon

我从https://github.com/iconic/open-iconic下载了一堆图标 图标原本是黑色的.png格式。

我想在我的 canvas 之一上添加一个向上的箭头。

我找到了一种导入图标的方法,但问题是我无法更改图标颜色。我可以在 Kivy 中更改图标颜色,还是需要为我将使用的每种颜色创建一个单独的 .png 图像?

<VitalBoard>:
canvas:
    Color:
        rgba: 0.17, 0.89, 0.89, 1
        hsv: 0.48, 0.80, 0.34
    Rectangle:
        pos: root.width * 2 / 3 + 20, root.height * 13 / 24 + 20
        size: root.width * 2 / 6 - 10 , root.height * 9 / 24 - 20
Label:
    font_size: 70
    text: "0"
    pos: root.width * 2 / 3 + 20, root.height * 13 / 24 + 20
    size: root.width * 2 / 6 - 10 , root.height * 9 / 24 - 20
    Image:
        source: 'open-iconic/png/arrow-thick-top-8x.png'
        pos: root.width * 2 / 3 + 20, root.height * 13 / 24 + 20
        size: root.width * 2 / 6 - 10 , root.height * 9 / 24 - 20
        width: 74

Kivy 在图像上有颜色属性 https://kivy.org/docs/api-kivy.uix.image.html#kivy.uix.image.Image.color

黑色和透明好像没被它改过。但是白色是可以改的。

GridLayout:
    cols:4
    canvas.before:
        Color:
            rgba: [1,1,1,1]
        Rectangle:
            pos: self.pos
            size: self.size

    Image:
        source: 'arrow-bottom-8x.png'
    Image:
        source: 'arrow-bottom-8x.png'
        color: [1,0,0,1]
    Image:
        source: 'arrow-bottom-8x.png'
        color: [0,1,0,1]
    Image:
        source: 'arrow-bottom-8x.png'
        color: [0,0,1,1]
    Image:
        source: 'download.png'
    Image:
        source: 'download.png'
        color: [1,0,0,1]
    Image:
        source: 'download.png'
        color: [0,1,0,1]
    Image:
        source: 'download.png'
        color: [0,0,1,1]

我认为您需要手动或在 kivy 之外进行。你可能想看看这里,例如