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 :)
You forgot to declare root - root = Tk()
.
The Tk system must be ON before using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With