title: How to change Tkinter button image on click?
body: <p>I have two images for a single button and also I created buttons with images. I would like to change the button image whenever I first click it. For example when I click the button I want button image to change &quot;UnclickedImage&quot; to &quot;ClickedImage&quot;.</p>
  <p>I could not be able to find any similar question in stackoverflow.</p>
  <pre><code>from tkinter import *
  
  
  class Example(Frame):
  
      def __init__(self, tk=None):
          super().__init__()
          self.tk = tk
          self.init_ui()
  
      def init_ui(self):
  
          self.photoTodo = PhotoImage(file=&quot;./Images/TodoUnClicked.png&quot;)
          Button(self.tk, image=self.photoTodo).pack(side=LEFT)
          self.photoStayFocussed = PhotoImage(file=&quot;./Images/StayFoccusedUnClicked.png&quot;)
          Button(self.tk, image=self.photoStayFocussed).pack(side=RIGHT)
  
  
  def main():
  
      root = Tk()
      root.configure(bg='white')
      ex = Example(root)
      root.title('')
      root.iconbitmap('./Images/empty.ico')
      root.geometry(&quot;400x100+300+300&quot;)
      root.mainloop()
  
  
  if __name__ == '__main__':
      main()
  </code></pre>