Problem with PIL/Tkinter Program Example

Peter Otten __peter__ at web.de
Thu Apr 9 13:01:31 CEST 2009


W. eWatson wrote:

> Something is amiss here. The program produces a canvas in which one can
> move an object around. The input file is hard coded (see open). If you
> want to try it, you'll need to provide a file. Python error below. Name
> space difficulty?

> Traceback (most recent call last):
>    File
> "C
\Sandia_Meteors\Sentinel_Development\Development_Sentuser-Utilities\Playground\fun-move_object.py",
> line 45, in <module>
>      Demo(root)
>    File
> "C
\Sandia_Meteors\Sentinel_Development\Development_Sentuser-Utilities\Playground\fun-move_object.py",
> line 35, in Demo
>      data.img=ImageTk.PhotoImage(img)
> NameError: global name 'ImageTk' is not defined

If you want to use the ImageTk module you have to import it first:

> #Mouse movement
> from Tkinter import *
> import PIL
> import Image

  import ImageTk

[rest of your code here]

Peter



More information about the Python-list mailing list