Python tkinter Basic Exercise: Create a window and Set its title and add a label to the window
Python tkinter Basic: Exercise-2 with Solution
Write a Python GUI program to import Tkinter package and create a window. Set its title and add a label to the window.
import tkinter as tk parent = tk.Tk() parent.title("-Welcome to Python tkinter Basic exercises-") my_label = tk.Label(parent, text="Label widget") my_label.grid(column=0, row=0) parent.mainloop()
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python GUI program to import Tkinter package and create a window and set its title.
Next: Write a Python GUI program to create a label and change the label font style (font name, bold, size) using tkinter module.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
You can chain comparison operators in Python as following: n = 10 result = 1 < n < 20
distance = 200 checker = 100 < distance < 350 print(checker)
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework