用kivy语言设置实例的颜色

2024-04-20 09:34:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有任何方法可以设置.kv文件中圆实例的颜色?你知道吗

我的.kv文件:

<Circle>:
    canvas:
        Ellipse:
            pos: self.pos
            size: self.size
<MyClass>:
    circle1: _circle1
    circle2: _circle2

    Circle:
        id: _circle1
        size: 250,250
        center_x: self.parent.width / 4
        center_y: self.parent.height / 2

    Circle:
        id: _circle2
        size: 250,250
        center_x: self.parent.width * 3/4
        center_y: self.parent.height / 2

Tags: 文件方法posselfidsizewidthparent
1条回答
网友
1楼 · 发布于 2024-04-20 09:34:08

您可以使用颜色Go here阅读画布上的更多内容。你知道吗

你可以用画布。之前, 画布后,与自我画布根据你的需要还有其他一些方法。你知道吗

请记住,它从0-1获取值,而不是从0-255获取值。 所以如果你有一个介于0-255之间的值,那就把它除以255,然后使用它。你知道吗

   <Circle>: 
        canvas.before:
            Color:
                rgba: .2,.5,.5,1
            Ellipse::   
                pos: self.pos
                size: self.size

下面是github上的colorpicker.py颜色选择。你知道吗

相关问题 更多 >