Python Devlopment






Label



It refers to the display box where you can put any text or image which can be updated any time as per the code.
The general syntax is:

mylabel=Label(root, option=value)
win is the parameter used to represent the parent window.

There are number of options which are used to change the format of the widget. Number of options can be passed as parameters separated by commas. Some of them are listed below.

  • bg: to set he normal background color.
  • bg to set he normal background color.
  • command: to call a function.
  • font: to set the font on the button label.
  • image: to set the image on the button.
  • width: to set the width of the button.
  • height” to set the height of the button.
Example:
from Tkinter import *
win=Tk()
win.title('My Label GUI')
win.geometry('350x250') # This is for fixing GUI window Size
mylabel=Label(win,text="hgsolutions")
mylabel.pack()
win.mainloop()