title: Tkinter - Image won't show up on button despite keeping global reference
body: <p>I want to place a button in the upper right corner and have the button be an image. I understand about scoping/garbage-collection etc. and have seen all the other questions asked here that overlook this fact. </p>
  
  <p>However, I have tried numerous methods including creating a <code>self.photo</code> and declaring photo as a global variable. I'm actually not even convinced that that's the issue, because I declare the photo in the same scope as I call the <code>mainloop()</code>.</p>
  
  <p>My code right now (which is mostly borrowed from <a href="https://stackoverflow.com/questions/29641616/drag-window-when-using-overrideredirect">Drag window when using overrideredirect</a> since I'm not really familiar with tkinter):</p>
  
  <pre><code>import tkinter
  
  pink="#DA02A7"
  cyan="#02DAD8"
  blue="#028BDA"
  
  class Win(tkinter.Tk):
  
      def __init__(self,master=None):
          tkinter.Tk.__init__(self,master)
          self.overrideredirect(True)
          self._offsetx = 0
          self._offsety = 0
          self.bind('&lt;Button-1&gt;',self.clickwin)
          self.bind('&lt;B1-Motion&gt;',self.dragwin)
          self.geometry("500x500")
  
      def dragwin(self,event):
          x = self.winfo_pointerx() - self._offsetx
          y = self.winfo_pointery() - self._offsety
          self.geometry('+{x}+{y}'.format(x=x,y=y))
  
      def clickwin(self,event):
          self._offsetx = event.x
          self._offsety = event.y
  
  win = Win()
  
  # put a close button
  close_button = tkinter.Button(win, bd=0, command=win.destroy)
  global photo
  photo=tkinter.PhotoImage("close.gif")
  close_button.config(image=photo, height="10", width="10")
  
  # pack the widgets
  close_button.pack(anchor=tkinter.NE)
  
  win.configure(bg=pink)
  
  win.mainloop()
  </code></pre>