Tkinter #2 Label: Label and attributes of label
Tkinter #2 Label: Label and attributes of label
In the tkinter label are used to show the text on window. the label is such type of attribute with which user cannot be interact. Labels are simply used to show the plain text on UI window.
syntax for label:
***************
a = label(attributes separated by coma)
ex.
a = label(text='hello',padx=80)
a.pack()
***************
Attributes for label:
- text = this is used to add text in ui window
- bg = This is used to add background color to the label
- fg = this is used to add text color to label
- font = This is used to adjust style ,size of font.
- padx = to adjust text or other toward x inside border
- pady = to adjust text or other toward y inside border
- image = to add the image
- width = to set the width of label
- height = to set the height of label
- command = to trigger any function
To set the border following attributes must be used
- borderwidth = integer any
- relief = to add the style to border = SUNKIN,RIDGE,GROOVE
syntax to use font attribute
Following will show you how to use text attribute
syntax = "font_name font_size font_style"
***************
a = label(text='hello', font="cryspo 50 bold")
a.pack()
***************
Comments
Post a Comment