विंडो में लेबल बनाने के लिए टिंकर लेबल विजेट का उपयोग किया जाता है। हम tkinter.ttk पैकेज का उपयोग करके विजेट्स को स्टाइल कर सकते हैं। लेबल विजेट के फ़ॉन्ट-आकार, फ़ॉन्ट-परिवार और फ़ॉन्ट-शैली का आकार बदलने के लिए, हम font('font-family font style', font-size) की इनबिल्ट प्रॉपर्टी का उपयोग कर सकते हैं। ।
उदाहरण
इस उदाहरण में, हम ऐसे बटन बनाएंगे जो लेबल टेक्स्ट की शैली को संशोधित करेंगे जैसे कि फ़ॉन्ट-आकार और फ़ॉन्ट-शैली।
#Import the required libraries
from tkinter import *
#Create an instance of tkinter frame
win= Tk()
#Set the geometry of frame
win.geometry("650x250")
#Define all the functions
def size_1():
text.config(font=('Helvatical bold',20))
def size_2():
text.config(font=('Helvetica bold',40))
#Create a Demo Label to which the changes has to be done
text=Label(win, text="Hello World!")
text.pack()
#Create a frame
frame= Frame(win)
#Create a label
Label(frame, text="Select the Font-Size").pack()
#Create Buttons for styling the label
button1= Button(frame, text="20", command= size_1)
button1.pack(pady=10)
button2= Button(frame, text="40", command=size_2)
button2.pack(pady=10)
frame.pack()
win.mainloop() आउटपुट
उपरोक्त कोड को चलाने पर एक टेक्स्ट लेबल वाली विंडो प्रदर्शित होगी। बटनों का उपयोग टेक्स्ट लेबल के फ़ॉन्ट-आकार को बदलने के लिए किया जा सकता है।

अब, टेक्स्ट लेबल विजेट के फ़ॉन्ट-आकार को बदलने के लिए चयन करें।
