Python Tkinter Label

aimtocode

Tkinter Label

Label is positioned in the grid in the widget.

The label can only display text in a single font, but the text may span more than one line.

Syntax:

                   
 w = Label ( master, option, ... )


Example:



Output:


Example:



Output:

Here, First Name and Last Name is label.


pack() method manages the layout of the particular widget in the parent widget. It has options as below

pack() Method Description
after=widget pack it after you have packed widget
anchor=NSEW (or subset) position widget according to
before=widget pack it before you will pack widget
expand=bool expand widget if parent size grows
fill=none or x or y or both fill widget if widget grows
in=master use master to contain this widget
in_=master see ‘in’ option description
ipadx=amount add internal padding in x direction
ipady=amount add internal padding in y direction
padx=amount add padding in x direction
pady=amount add padding in y direction
side=top or bottom or left or right where to add this widget.
aimtocode