![](/img/trans.png)
[英]Displaying an image with the Tkinter library — “too early to create image”
[英]Python Tkinter Error, “Too Early to Create Image”
所以我有一項任務,我必須使用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()
任何幫助,將不勝感激。 謝謝 :)
你忘了聲明root - root = Tk()
。 使用前,Tk系統必須處於打開狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.