Using Label in Python - The Advantages of Learning Python Programming for Beginners: A Comprehensive Guide

Latest

Dive into the world of Python programming with our comprehensive resources

Music

logo

Thursday, December 22, 2022

Using Label in Python

 

In this article, I will explain the use of label in Python. I am adding tkinter to my form. In the Title section, I enter a title in the form. The text that will appear on the label is written in the text part of the label. The background color of the Label object is determined by bg, and the text color is determined by fg. The font property defines the font and font size. The place of the label in the form is determined with padx and pady.

 


 

 

 

Figure 1

 

pyton_label.py

 

import tkinter as tk

 

root = tk.Tk()

root.title("label..bs")

 

str1="Life is like riding a bicycle,To keep your balance,You must keep moving -Albert Einstein"

 

lbl = tk.Label(root, text=str1, bg="black", fg="white",font=('arial',12,'normal'))

lbl.pack(fill=tk.X, padx=20,pady=10)

 

tk.mainloop()

 

I have come to the end of this article. See you in my next article. Happy coding. Bahadir Sahin

No comments:

Post a Comment

Featured post

Python Introduction

What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built ...