2012-04-19 68 views
9

所以我有一个任务,我必须使用Tkinter来创建一个棋盘游戏。这只是我想引入董事会形象的计划的一部分。但是我不断收到错误,“太早创建图像”,我不确定自己做错了什么。Python 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() 

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

回答

10

你忘了声明根 - root = Tk()。 Tk系统在使用前必须打开。

+0

这样做。谢谢! – emagdnim 2012-04-19 21:28:30