วิดเจ็ตของ Tkinter รองรับคุณสมบัติและแอตทริบิวต์ต่างๆ เช่น ตระกูลแบบอักษรและขนาดแบบอักษร ซึ่งสามารถระบุได้โดยใช้ แบบอักษร ('Font-Family', ขนาดแบบอักษร) ทรัพย์สิน
ตัวอย่าง
ในตัวอย่างต่อไปนี้ เราได้สร้างป้ายกำกับข้อความที่สามารถกำหนดค่าได้โดยการกำหนดชุดแบบอักษรเป็น "Times New Roman" และขนาดแบบอักษรเป็น "20"
#Import the tkinter library
from tkinter import *
#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("650x250")
#Add a text label and add the font property to it
label= Label(win, text= "This is a New Text", font=('Times New Roman bold',20))
label.pack(padx=10, pady=10)
win.mainloop() ผลลัพธ์
การเรียกใช้โค้ดด้านบนจะแสดงหน้าต่างหรือกรอบที่มีข้อความ
