I am attempting to use Tkinter for the first time on my computer, and I am getting the error in the title, "NameError: name 'Tk' is not defined", citing the "line root = Tk()". I have not been able to get Tkinter to work in any form. I am currently on a macbook pro using python 2.7.5. I have tried re-downloading python multiple times but it is still not working. Anyone have any ideas as to why it isn't working? Any more information needed from me?
Thanks in advance
#!/usr/bin/python
from Tkinter import *
root = Tk()
canvas = Canvas(root, width=300, height=200)
canvas.pack()
canvas.create_rectangle( 0, 0, 150, 150, fill="yellow")
canvas.create_rectangle(100, 50, 250, 100, fill="orange", width=5)
canvas.create_rectangle( 50, 100, 150, 200, fill="green", outline="red", width=3)
canvas.create_rectangle(125, 25, 175, 190, fill="purple", width=0)
root.mainloop()
You have some other module that is taking the name "Tkinter", shadowing the one you actually want. Rename or remove it.
import Tkinter
print Tkinter.__file__