The Tkinter module contains a "Image" class, so doing the "import *"
thing after all other imports will stomp out the Import module.
Either fix all uses of PIL to use fully qualified names (replace
"import Image" with "import PIL.Image", "Image.open" with
"PIL.Image.open" etc), or, easier, move the "from Tkinter import *"
line to the top of the imports.

</F>

On Wed, Apr 8, 2009 at 10:21 PM, Wayne Watson
<sierra_mtnv...@sbcglobal.net> wrote:
> Still a problem.
>
> import PIL
> import Image
> from Tkinter import *
> ...
>   cnv.pack(expand=1,fill=BOTH)
>   data.cnv=cnv
>   img=Image.open('jupa9810.jpg')  # some image you have.....
>   data.img=ImageTk.PhotoImage(img)
>
> produces:
> Traceback (most recent call last):
>  File
> "C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser-Utilities\Playground\fun-move_object.py",
> line 44, in <module>
>   Demo(root)
>  File
> "C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser-Utilities\Playground\fun-move_object.py",
> line 33, in Demo
>   img=Image.open('jupa9810.jpg')  # some image you have.....
> AttributeError: class Image has no attribute 'open'
>
>
> Fredrik Lundh wrote:
>>
>> On Wed, Apr 8, 2009 at 5:55 PM, Edward Cannon <cannon...@gmail.com> wrote:
>>
>>>
>>> Add the line
>>> from Tkinter import
>>>
>>
>> Lost an asterisk there, I think:
>>
>>   from Tkinter import *
>>
>> </F>
>>
>>
>>>
>>> On Apr 7, 2009, at 10:21 PM, Wayne Watson <sierra_mtnv...@sbcglobal.net>
>>> wrote:
>>>
>>>
>>>>
>>>> This looks good, but there's a slight problem. It looks right, but I get
>>>> this when I try to run it:
>>>> Traceback (most recent call last):
>>>> File
>>>>
>>>> "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/Playground/fun-move_object.py",
>>>> line 42, in <module>
>>>>  root=Tk()
>>>> NameError: name 'Tk' is not defined
>>>>
>>>> Howard Lightstone wrote:
>>>>
>>>>>
>>>>> Here is a *dumb* example of what I think you want.  It can be
>>>>> elaborated
>>>>> with crosshairs, ring sizing, etc.
>>>>>
>>>>> import PIL
>>>>> import Image
>>>>> import ImageTk
>>>>>
>>>>> class data:
>>>>>  startx=0
>>>>>  starty=0
>>>>>
>>>>> def startmotioncallback(event):
>>>>>  data.startx=event.x
>>>>>  data.starty=event.y
>>>>>
>>>>>  def motioncallback(event):
>>>>>  deltax=event.x-data.startx
>>>>>  deltay=event.y-data.starty
>>>>>  data.startx=event.x
>>>>>  data.starty=event.y
>>>>>  # should put some limits on where the cirle is moved
>>>>>  # left as exercise.....
>>>>>  data.cnv.move(data.ring,deltax,deltay)
>>>>>  def Demo(root):
>>>>>  # resize window
>>>>>  root.geometry('400x400+0+0')
>>>>>  data.root=root
>>>>>  # make a canvas
>>>>>  cnv=Canvas(root)
>>>>>  cnv.pack(expand=1,fill=BOTH)
>>>>>  data.cnv=cnv
>>>>>  img=Image.open('white dragon.png')  # some image you have.....
>>>>>  data.img=ImageTk.PhotoImage(img)
>>>>>  data.photo=cnv.create_image(0,0,image=data.img,anchor='nw')
>>>>>  data.ring=cnv.create_oval((100,100,300,300))
>>>>>  cnv.bind("<B1-Motion>",motioncallback)
>>>>>  cnv.bind("<Button-1>",startmotioncallback)
>>>>>  root.mainloop()
>>>>>
>>>>> if __name__ == '__main__':
>>>>>
>>>>>  root=Tk()
>>>>>  Demo(root)
>>>>> _______________________________________________
>>>>> Image-SIG maillist  -  image-...@python.org
>>>>> http://mail.python.org/mailman/listinfo/image-sig
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>>
>>>>        Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>>>>
>>>>          (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
>>>>
>>>>       "Less than all cannot satisfy Man." -- William Blake
>>>>
>>>>
>>>> _______________________________________________
>>>> Image-SIG maillist  -  image-...@python.org
>>>> http://mail.python.org/mailman/listinfo/image-sig
>>>>
>>>
>>> _______________________________________________
>>> Image-SIG maillist  -  image-...@python.org
>>> http://mail.python.org/mailman/listinfo/image-sig
>>>
>>>
>>
>>
>
> --
>
>          Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>            (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
>
>         "Less than all cannot satisfy Man." -- William Blake
>
>
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to