作者guteres (肝...是用来爆的...= =)
看板Python
标题[问题] 图片读取的问题....
时间Mon Nov 27 23:48:55 2006
各位好
我现在在写一个读入图片的简单程式如下:
from Tkinter import *
import Image, ImageTk
win = Tk()
imgFile = Image.open("D:\\lena.bmp")
img = ImageTk.PhotoImage(imgFile)
canvas = Canvas(win, width=400, height=630)
canvas.create_image(40, 40, image=img, anchor=NW)
canvas.pack(fill=BOTH)
可是一执行就出现了下面的错误
Traceback (most recent call last):
File "D:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310,
in RunScript
exec codeObject in __main__.__dict__
File "D:\work\prog\ex3.py", line 9, in <module>
canvas.create_image(40, 40, image=img, anchor=NW)
File "D:\Python25\Lib\lib-tk\Tkinter.py", line 2154, in create_image
return self._create('image', args, kw)
File "D:\Python25\Lib\lib-tk\Tkinter.py", line 2145, in _create
*(args + self._options(cnf, kw))))
TclError: image "pyimage11" doesn't exist
只要一执行到canvas.create_image(...)就会出错
请问版上有网友有没有解决的方法
PS:我用的IDE是pythonwin,如果换用内建的IDEL就没有问题
--
████████
████████
^
█ /▔▔▔▔▔╲
█ ○
█===================| █◣ ╲
█ \ ██ ╰╮
\ │
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.13.137.91
※ 编辑: guteres 来自: 163.13.137.5 (11/28 11:04)