AttributeError when creating tkinter.PhotoImage object with PIL.ImageTk
<p>I am trying to place an image resized with PIL in a tkinter.PhotoImage object. </p>

<pre><code>import tkinter as tk # I use Python3
from PIL import Image, ImageTk

master = tk.Tk()
img =Image.open(file_name)
image_resized=img.resize((200,200))
photoimg=ImageTk.PhotoImage(image_resized)
</code></pre>

<p>However, when I later try to call </p>

<pre><code>photoimg.put( "#000000", (0,0) )
</code></pre>

<p>I get an</p>

<pre><code>AttributError: 'PhotoImage' object has no attribute 'put'
</code></pre>

<p>While this:</p>

<pre><code>photoimg=tk.PhotoImage(file=file_name)
photoimg.put( "#000000", (0,0))
</code></pre>

<p>doesn't raise an error.
What am I doing wrong?</p>

<p><code>ImageTk.PhotoImage</code> as in <code>PIL.ImageTk.PhotoImage</code> is not the same class as <code>tk.PhotoImage</code> (<code>tkinter.PhotoImage</code>)  they just have the same name</p>

<p>here is ImageTk.PhotoImage docs:
<a href="http://pillow.readthedocs.io/en/3.1.x/reference/ImageTk.html#PIL.ImageTk.PhotoImage" rel="nofollow">http://pillow.readthedocs.io/en/3.1.x/reference/ImageTk.html#PIL.ImageTk.PhotoImage</a>
 as you can see there is no put method in it.</p>

<p>but <code>ImageTk.PhotoImage</code> do have it:
<a href="http://epydoc.sourceforge.net/stdlib/Tkinter.PhotoImage-class.html" rel="nofollow">http://epydoc.sourceforge.net/stdlib/Tkinter.PhotoImage-class.html</a></p>

python tkinter python-imaging-library photoimage