Python Tkinter Error, “Too Early to Create Image”


Python Tkinter Error, “Too Early to Create Image”



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.



Here's my code so far:


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:UsersKikiDesktopAssignment\")
photo = can.create_image(0,0,anchor=NW, image=im)

can.pack()


root.mainloop()



Any help would be appreciated. Thanks :)




1 Answer
1



You forgot to declare root - root = Tk().
The Tk system must be ON before using it.


root = Tk()





That did it. Thanks!
– emagdnim
Apr 19 '12 at 21:28






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

List of Kim Possible characters

Audio Livestreaming with Python & Flask

NSwag: Generate C# Client from multiple Versions of an API