Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Tkinter Error, "Too Early to Create Image"

Tags:

python

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.

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

can.pack()


root.mainloop()

Any help would be appreciated. Thanks :)

like image 594
Stephen Roda Avatar asked Apr 19 '12 21:04

Stephen Roda


1 Answers

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

like image 172
Israel Unterman Avatar answered Sep 25 '22 12:09

Israel Unterman