首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何解决Python Tkinter错误,“过早创建图像”?

如何解决Python Tkinter错误,“过早创建图像”?
EN

Stack Overflow用户
提问于 2018-08-03 00:39:04
回答 1查看 0关注 0票数 0

我有一个任务,我必须使用Tkinter来创建一个棋盘游戏。这只是程序的一部分,我想在其中引入董事会的形象。但是我不断地得到错误,“太早,不能创建图像”,我不知道我做错了什么。

到目前为止,我的代码如下:

代码语言:txt
复制
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()
EN

回答 1

Stack Overflow用户

发布于 2018-08-03 10:22:49

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100001888

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档