所以我在 python3 guizero 中编写了这段代码,当我单击我创建的按钮时将颜色变为红色。但无论我做什么,它都不起作用!我不确定我做错了什么,但它不起作用(我使用了 Visual Studio Code,但它没有给我任何错误或说代码错误。)所以我认为这将是最好的选择。这是我写的代码:
from guizero import *
red = 255,0,0
def cl_ch():
if mahe_pushbutton.text == "Push":
mahe_text.text_colour = red
else:
print("Not working")
mahe_app = App(title = "TEST")
mahe_text = Text(mahe_app, text = "test test", font = "Orbitron", size = 20)
mahe_textbox = TextBox(mahe_app, width = 50)
mahe_pushbutton = PushButton(mahe_app, command=cl_ch, text = "Push")
mahe_pushbutton.width = 60
mahe_pushbutton.height = 3
mahe_app.display()
感谢您能提供帮助!