title: Python tkinter image, function not working
body: <pre><code>import pyautogui
  import tkinter as tk
  from PIL import Image
  from PIL import ImageTk
  
  root = tk.Tk()
  root.title('capture')
  canvas1 = tk.Canvas(root, width = 400, height = 100)
  canvas1.pack()
  
  on = tk.PhotoImage(file = 'D:/on.png')
  off = tk.PhotoImage(file = 'D:/off.png')
  
  def myScreenshot(event):
      myScreenshot = pyautogui.screenshot()
      myScreenshot.save('C:/Users/*Username/Desktop/capture.jpg')
  
  def capture():
      if onButton['image'] == on:
          onButton['image'] = on
          root.bind('&lt;Shift-Z&gt;', myScreenshot)
  
      else:
          root.unbind('&lt;Shift-Z&gt;')
          onButton['image'] = off
          
  
  onButton = tk.Button(image = on, command=capture)
  canvas1.create_window(200, 50, window=onButton)
  
  root.mainloop()
  </code></pre>
  <p>so I have 2 questions;</p>
  <ol>
  <li><p>What I intended is after I press 'on' button, whenever I press Shift + Z, it will capture my whole screen. However it is not working for some reason. There is no error.</p>
  </li>
  <li><p>I want to let 'on' button return when I click 'off' button. But it is not working. Only works 'on' to 'off'</p>
  </li>
  </ol>
  <p>Thanks in advance</p>