问题 Python Tkinter错误,“太早创建图像”


所以我有一项任务,我必须使用Tkinter来创建棋盘游戏。这只是我希望引入电路板图像的程序的一部分。但我继续得到错误,“太早创建图像”,我不知道我做错了什么。

到目前为止,这是我的代码:

from Tkinter import *
from pprint import pprint

# Which variable is currently updating
from variableColors import Variables
VariableIndex = 0               
VariableText = Variables[VariableIndex]

Ids = None             # Current canvas ids of the text and 4 player tokens:
                       # Will be None if not committed

VariableCoords = { }       # Where store variable and coordinates


im = PhotoImage(file="C:\Users\Kiki\Desktop\Assignment\\")
photo = can.create_image(0,0,anchor=NW, image=im)

can.pack()


root.mainloop()

任何帮助,将不胜感激。谢谢 :)


7930
2018-04-19 21:12


起源



答案:


你忘了申报root - root = Tk()。 使用前,Tk系统必须处于打开状态。


13
2018-04-19 21:16



这样做了。谢谢! - emagdnim


答案:


你忘了申报root - root = Tk()。 使用前,Tk系统必须处于打开状态。


13
2018-04-19 21:16



这样做了。谢谢! - emagdnim