代码之家  ›  专栏  ›  技术社区  ›  Tomas By

Kivy ToggleButtons中的反转颜色

  •  0
  • Tomas By  · 技术社区  · 6 年前

    background_down: 'btn_prs_grn.png'
    on_state: self.color = [0,0,0,1] if self.state == 'down' else [0,1,0,1]
    

    使(我认为)积极的按钮黑色的绿色,但我得到的是更像是稍微深绿色的正常绿色。

    编辑

    enter image description here

    左键正常,右键向下。实际上,在右边的按钮上可以辨认出“白色”的文字,颜色比正常按钮略深一点的绿色。

    什么是最简单的方法来实现黑对绿?我知道我自己可以在画布上画画,但有没有更简单的方法?

    1 回复  |  直到 6 年前
        1
  •  0
  •   ikolim    6 年前

    输出-切换按钮

    Img01

    在kv文件中,设置 background_normal: ''

    background_color

    background_color
    

    背景色,格式为(r、g、b、a)。

    这将作为纹理颜色的倍增器。 默认值 更暗的结果。要设置纯色,请将背景设置为“法线” ''.

    background_normal

    background_normal
    

    用于默认图形的按钮的背景图像

    background\u normal是StringProperty,默认为