Python Tkinter: “‘Label’ unresolved” error

0 votes

Hi. I am getting “Label unresolved” error in my python code. Please help me solve it:

import Tkinter as tk

root = tk.Tk()

Label(root, text="Red Sun", bg="red", fg="white").pack()

Label(root, text="Green Grass", bg="green", fg="black").pack()

Label(root, text="Blue Sky", bg="blue", fg="white").pack()
May 8 in Python by Kumar
6 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You have imported Tkinter as tk but you are trying to call the Label method directly.

Either call Label from tk.

import Tkinter as tk

root = tk.Tk()

tk.Label(root, text="Red Sun", bg="red", fg="white").pack()

tk.Label(root, text="Green Grass", bg="green", fg="black").pack()

tk.Label(root, text="Blue Sky", bg="blue", fg="white").pack()

or

Don’t import Tkinter as any other name, just use

from Tkinter import *
answered May 8 by Rishi

Related Questions In Python

+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
33 views
0 votes
1 answer

How to get text label from SAP using pywinauto[python]

Hi. Can you please tell me what ...READ MORE

answered Jun 28, 2018 in Python by Nietzsche's daemon
• 4,260 points
209 views
0 votes
2 answers

Indentation Error in Python

Use tabs instead of spaces. This is ...READ MORE

answered Feb 14 in Python by Shashank
• 1,350 points
46 views
0 votes
1 answer

Is there a label/goto in Python?

No, Python does not support labels and ...READ MORE

answered Aug 1, 2018 in Python by Priyaj
• 56,120 points
83 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
25 views
+4 votes
6 answers
0 votes
1 answer

Tkinter “module not callable” error.

Tk() is a module and not a ...READ MORE

answered May 8 in Python by Yash
68 views
0 votes
1 answer

How to set window size in Tkinter Python?

The window size adjustment can be done ...READ MORE

answered May 8 in Python by Giri
11 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.