【发布时间】:2021-01-25 02:18:42
【问题描述】:
我是 Python 新手,肯定有一个简单的答案。感谢您的帮助,这是我的代码 :)
def Button1B():
if button1['image'] == play:
button1['image'] = loop
play=PhotoImage(file="play.png")
loop=PhotoImage(file="loop.png")
button1=Button(frame, image=play, bg="#292929", bd=0, activebackground="#292929", cursor="hand2", command=Button1B)
button1.place(x=15, y=450)
【问题讨论】:
-
如果你在创建
play之后执行print(play),你会得到类似pyimage的东西。所以 if 语句总是被评估为 False。