问题描述
在Tkinter画布上创建图像时,我总是收到此错误。
Traceback (most recent call last):
File "C:\my\user\folder\Documents\main.py",line 123,in <module>
exec(gamecmdss)
File "<string>",line 1,in <module>
File "C:\my\folder\main.py",line 66,in STANDARD_createimage
gamestuff["parts"][id]["realid"] = gamecanvas.create_rectangle(coords,image=img,tags=[imgtype,"Pinecone image obj"])
File "C:\my\user\folder\AppData\Local\Programs\Python\python37-32\lib\tkinter\__init__.py",line 2501,in create_rectangle
return self._create('rectangle',args,kw)
File "C:\my\user\folder\AppData\Local\Programs\Python\python37-32\lib\tkinter\__init__.py",line 2480,in _create
*(args + self._options(cnf,kw))))
_tkinter.TclError: wrong # coordinates: expected 0 or 4,got 2
def STANDARD_createimage(id,xpos,ypos,file,imgtype=imgtype_graphic):
global gamecanvas
global gamewindow
global gamestuff
gamewindow.config(cursor="@thinking.cur")
coords = xpos,ypos
img = tk.PhotoImage(file=file)
if not imgtype in imgtypes:
print(f"UnkNown image type '{imgtype}',defaulting to imgtype_graphic")
imgtype = imgtype_graphic
gamestuff["parts"][id] = {}
gamestuff["parts"][id]["realid"] = gamecanvas.create_rectangle(coords,"Pinecone image obj"]) #here is the problem
gamewindow.config(cursor="@default.cur")
showinfo()
这是我一直运行的代码:
STANDARD_createimage("image",50,"C:/my/user/folder/Documents/exampleimage.png");
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)