Skip to content

How to make a label in Python tkinter?

The Tkinter Label is used to specify the container box where we can place the text or images. This widget is used to provide the message to the user about other widgets used in the python application.

Syntax

w = Label (master, options)  

Example

myLabel = Label(screen_name, text="")
myLabel.place(x="", y="")
# !/usr/bin/python3  
  
from tkinter import *  
  
top = Tk()  
  
top.geometry("400x250")  
  
#creating label  
username = Label(top, text = "Username").place(x = 30,y = 50)  
  
#creating label  
password = Label(top, text = "Password").place(x = 30, y = 90)  
  
  
submitBtn = Button(top, text = "OK",activebackground = "green", activeforeground = "cyan").place(x = 30, y = 120)  
  
e1 = Entry(top,width = 20).place(x = 100, y = 50)  
  
  
e2 = Entry(top, width = 20).place(x = 100, y = 90)  
  
  
top.mainloop()  
See also  How to darken background image with CSS?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.