【问题标题】:change the On_press color of button in KIVY更改 KIVY 中按钮的 On_press 颜色
【发布时间】:2021-02-01 22:45:50
【问题描述】:

上面是按下按钮时的按钮颜色。
在 .kv 文件中,我给出了 # 仅作为示例

Button:
                text:"Click here to print Hello world  "
                size_hint:[.9, .1]
                on_press: print("Hello world")

如何更改按钮的 on_press 颜色?

要求更改在 .kv 文件中

【问题讨论】:

    标签: python kivy


    【解决方案1】:

    您可以使用Buttonbackground_down 属性设置按下Button 时的背景颜色。不幸的是,background_down 必须是图像,而不是颜色元组。但是图像本身可以只是 1 像素乘 1 像素的图像。例如,使用名为 red.png 的 1 x 1 像素图像作为 background_down

    Button:
        text:"Click here to print Hello world  "
        size_hint:[.9, .1]
        on_press: print("Hello world")
        background_down: 'red.png'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 2020-03-10
      相关资源
      最近更新 更多