Tkinter GUI window and Label in Python

Hello friends how are you, today in this blog i will teach you what is Tkinter, how to create GUI window , how Tkinter GUI works and many programs using Tkinter in a very simple way.

Let's start

Python tkinter

  • Tkinter is GUI library for Python.
  • It is used to create graphical user interface for desktop application.
  • import the tkinter module in python program.
  • Create the GUI main window.
  • Add the widgets like labels, buttons etc. to the GUI window.
  • Call the main loop so that the actions can take place on the user's computer screen.

#importing tkinter
import tkinter
#creating object
top = tkinter.Tk()
# Code to add widgets will go here...
#calling mainloop

import tkinter
top = tkinter.Tk()
#setting dimension of window

import tkinter
top = tkinter.Tk()
#setting dimension of window
#setting title of window
#setting background color


  • The Label widget is used to provide a caption for other widgets.
  • It can be used as a heading.
  • It can also contain images.
  • Syntax:
    lbl = Label ( master, option1,option2, ... )
  • Here master is parent window and option can be used as a key-value pairs.
  • Examples of options are text,bg,image,height etc.

from tkinter import *
top = Tk()
#window dimension
# creating label
uname = Label(top, text="This is a label").place(x=30, y=50)
  • Here x is distance from left and y is distance from top.

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 


Post a Comment