Labels not defined in tkinter app
You never imported the
Label class. Try
Check the import statements for those tutorials
Maybe they imply
from tkinter import *
AgentL3rUpdated on July 06, 2022
AgentL3r 6 months
I'm trying to make a basic window with the text "t" inside using Tkinter, however when running the code the shell spits out "NameError: name 'Label' is not defined". I'm running Python 3.5.2.
I followed the tutorials but the problem is in the
label = Label(root, text="test")line.
import tkinter root = tkinter.Tk() sheight = root.winfo_screenheight() swidth = root.winfo_screenwidth() root.minsize(width=swidth, height=sheight) root.maxsize(width=swidth, height=sheight) label = Label(root, text="test") label1.pack() root = mainloop()
Is the label function different in 3.5.2?
Andrew Li about 6 yearsDid mean
tkinter.Labeldue to how you imported it?
Labelis a class, not function.
Russell Smith about 3 yearsYou need to properly format the code in your answer. See How do I format my code blocks
Critical issues have been reported with the following SDK versions: com.google.android.gms:play-services-safetynet:17.0.0