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 9, 2019 in Python by Kumar
3,040 views

1 answer to this question.

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 9, 2019 by Rishi

Related Questions In Python

0 votes
2 answers

Python error "ImportError: No module named 'tkinter'"

sudo apt-get install python3-tk Then, >> import tkinter # ...READ MORE

answered Nov 9, 2019 in Python by Icetutor
• 160 points
24,289 views
0 votes
1 answer

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

answered Apr 27, 2020 in Python by MD
• 95,440 points
12,758 views
0 votes
0 answers

Why do i get this error in tkinter - Python?

This is my code: from tkinter import * root ...READ MORE

Oct 10, 2021 in Python by LogizTV
• 120 points
503 views
+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
5,346 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,055 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,474 views
0 votes
2 answers

Tkinter “module not callable” error.

This error statement TypeError: 'module' object is ...READ MORE

answered Jun 27, 2019 in Python by rahul
• 360 points
20,528 views
0 votes
1 answer

How to set window size in Tkinter Python?

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

answered May 9, 2019 in Python by Giri
3,553 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP