简体   繁体   English

在kivy中单击时如何更改按钮颜色

[英]How to change button color when clicked in kivy

I am trying to change the button color when pressed to green.我试图在按下绿色时更改按钮颜色。 But it is somehow not working?但它不知何故不起作用? Could anybody help?有人可以帮忙吗?

            Button:
               pos_hint:{"top": 1,"left": 1}
               size_hint:1,1
               text: "20"
               size: 30,30
               on_release:
                  background_color:1, 0, 0, 0

Try this:尝试这个:

               on_release:
                  self.background_color = 1, 0, 0, 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM