_tkinter.TclError:未知选项“pyimage2”

时间:2015-01-06 18:46:37

标签: python tkinter tkinter-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"

1 个答案:

答案 0 :(得分:2)

canvas.create_image(170, space_y[current_space["1a"]], counter1)

这里的功能签名似乎有问题。 create_image期望position元组加上关键字参数。尝试:

canvas.create_image((170, space_y[current_space["1a"]]), image=counter1)

现在您的应用程序运行时没有任何明显的错误。

enter image description here