Python Tkinter 错误,“创建图像为时过早" [英] Python Tkinter Error, "Too Early to Create Image"
本文介绍了Python Tkinter 错误,“创建图像为时过早"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有一个任务,我必须使用 Tkinter 来创建一个棋盘游戏.这只是我想引入董事会形象的程序的一部分.但我不断收到错误消息,创建图像为时过早",而且我不确定自己做错了什么.
So I have an assignment that I have to use Tkinter to create a board game. This is just one part of the program where I want to bring in the image of the board. But I keep on getting the error, "Too early to create image" and I'm not sure what I'm doing wrong.
这是我目前的代码:
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()
任何帮助将不胜感激.谢谢:)
Any help would be appreciated. Thanks :)
推荐答案
您忘记声明 root - root = Tk()
.Tk系统必须在使用前开启.
You forgot to declare root - root = Tk()
.
The Tk system must be ON before using it.
这篇关于Python Tkinter 错误,“创建图像为时过早"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文