2012-04-19 87 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