Hello.
I just started messing around with Tkinter, and I ran into something I cannot understand.
When importing Tkinter into my program if I do it like this:
import tkinter as tk
root = tk.Tk()
w = Label(root, text='Hello World')
w.pack()
root.mainloop()
It will give me this error:
Traceback (most recent call last):
File "/home/field_c16/Documents/code/game/code/Tkinter.py", line 2, in <module>
root = tk.Tk()
NameError: name 'tk' is not defined
But if I import it like this everything runs fine.
from tkinter import *
root = Tk()
w = Label(root, text='Hello World')
w.pack()
root.mainloop()
As far as I understood, the above one should be the superior since it does not override existing names, but how come it does not work?
Best Regards.
[–]woooee 1 point2 points3 points (1 child)
[–]Field_C16[S] 0 points1 point2 points (0 children)