我有一个任务,我必须使用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()
发布于 2018-08-03 10:22:49
你忘了声明根-root = Tk()
。在使用Tk系统之前,必须先打开它。
https://stackoverflow.com/questions/-100001888
复制相似问题