Python Change Button Image and change it back -


so have code changes image of button when clicked. now, if wanted have button change when clicked , return normal? (like normal button) can't add .config method skip first 1 , keep button same image. can not wait freezes program , produces same result.

playup = photoimage(file=currentdir+'\up_image.gif') playdown = photoimage(file=currentdir+'\down_image.gif') #functions def playbutton():     pbutton.config(image=playdown)     return  #play button pbutton = button(root, text="play", command=playbutton) pbutton.grid(row=1) pbutton.config(image=playup) 

the best way make button image change real button press images this.

define photos:

playup = photoimage(file=currentdir+r'\up_image.gif') playdown = photoimage(file=currentdir+r'\down_image.gif') 

define functions:

def returncolor():     pbutton.config(image=playup) def playbutton():     pbutton.config(image=playdown)     pbutton.after(200,returncolor) 

initialize button:

#play button pbutton = button(root, text="play", command=playbutton, borderwidth=0) pbutton.grid(row=1) pbutton.config(image=playup) 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -