【发布时间】:2014-04-22 22:38:37
【问题描述】:
我在这里要做的是将图像添加到我拥有的按钮中,然后根据单击或悬停更改图像。我遵循的所有示例都使用.config() 方法。
对于我的生活,我无法弄清楚为什么它不知道按钮对象是什么。有趣的是,如果我修改 Button 定义行以包含图像选项,一切都很好。但是,似乎我无法使用.config()修改它
PlayUp = PhotoImage(file=currentdir+'\Up_image.gif')
PlayDown = PhotoImage(file=currentdir+'\Down_image.gif')
#Functions
def playButton():
pButton.config(image=PlayDown)
pButton = Button(root, text="Play", command="playButton").grid(row=1)
pButton.config(image=PlayUp)
【问题讨论】:
标签: python image button nonetype