title: Using an image as an class object attribute, then opening that image in a Tkinter label widget
body: <p>I'm new to python and have been messing around with Tkinter and now Pillow.</p>
  
  <p>I'm trying to make an image an attribute of a class, and then have that image open as an image in a Tkinter Label. Here's some sample code. My Tkinter windows are working right aside from when I try to do this exact thing, so if there are any errors in the Tkinter code below it's purely as a result of writing samples.</p>
  
  <pre><code>class PicTest:
      def __init__(self, name, image):
          self.name = name
          self.image = image
  
  foo = PicTest('foo', Image.open('foo.png'))
  </code></pre>
  
  <p>This opens the image in a new window</p>
  
  <pre><code>foo.image.show()
  </code></pre>
  
  <p>But this throws an error when I try to run it.</p>
  
  <pre><code>def testwindow:
      root = Tk()
  
      &lt;necessary code&gt;
  
      foo_testlabel = Label(root, image=foo.image, height=xxx, width=xxx)
      foo_testlabel.pack()
  
      mainloop()
  </code></pre>
  
  <p>The error that I get is:</p>
  
  <pre><code>_tkinter.TclError: image "&lt;PIL.PngImagePlugin.PngImageFile image mode=RGBA size=119x96 at 0x10D9FE240&gt;" doesn't exist
  </code></pre>
  
  <p>I've successfully achieved the result I want NOT using this method (using PhotoImage(file=xxxx) to open whatever I want within my Tkinter definition) but ideally the image is an attribute of the object so I can use it elsewhere.</p>
  
  <p>Any thoughts of the right way to do this?</p>
  
  <p>Thanks!</p>