_tkinter.TclError: unknown option "pyimage2"
_tkinter.TclError: unknown option "pyimage2"
我正在尝试将图像绘制到 canvas 上(从 place 到 canvas 的中间转换)并且出现此错误
hastebin 包含代码:
http://hastebin.com/tuciyisisa.py
Traceback (most recent call last):
File "D:\Stuff\python\Coursework\AQADo\main.py", line 82, in <module>
app = Application(master=root)
File "D:\Stuff\python\Coursework\AQADo\main.py", line 74, in __init__
self.drawCounter(space_y, current_space, game_canvas)
File "D:\Stuff\python\Coursework\AQADo\main.py", line 26, in drawCounter
canvas.create_image(170, space_y[current_space["1a"]], counter1)
File "C:\Python34\lib\tkinter\__init__.py", line 2291, in create_image
return self._create('image', args, kw)
File "C:\Python34\lib\tkinter\__init__.py", line 2282, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: unknown option "pyimage2"
canvas.create_image(170, space_y[current_space["1a"]], counter1)
您的函数签名似乎有问题。 create_image
需要一个 position
元组,加上关键字参数。尝试:
canvas.create_image((170, space_y[current_space["1a"]]), image=counter1)
现在您的应用程序运行起来没有任何明显的错误。
我正在尝试将图像绘制到 canvas 上(从 place 到 canvas 的中间转换)并且出现此错误
hastebin 包含代码: http://hastebin.com/tuciyisisa.py
Traceback (most recent call last):
File "D:\Stuff\python\Coursework\AQADo\main.py", line 82, in <module>
app = Application(master=root)
File "D:\Stuff\python\Coursework\AQADo\main.py", line 74, in __init__
self.drawCounter(space_y, current_space, game_canvas)
File "D:\Stuff\python\Coursework\AQADo\main.py", line 26, in drawCounter
canvas.create_image(170, space_y[current_space["1a"]], counter1)
File "C:\Python34\lib\tkinter\__init__.py", line 2291, in create_image
return self._create('image', args, kw)
File "C:\Python34\lib\tkinter\__init__.py", line 2282, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: unknown option "pyimage2"
canvas.create_image(170, space_y[current_space["1a"]], counter1)
您的函数签名似乎有问题。 create_image
需要一个 position
元组,加上关键字参数。尝试:
canvas.create_image((170, space_y[current_space["1a"]]), image=counter1)
现在您的应用程序运行起来没有任何明显的错误。