ภาพรวม
Tkinter Labels ใช้สร้างและแสดง Text หรือ Image บนหน้าต่าง มี Components และ Functions ปรับแต่ง Label เช่น Font-family, Padding, Width, Height เพื่อดึง Label Text บนหน้าต่าง เขียนค่า Text ที่จะแสดงบนหน้าต่าง
ตัวอย่างโค้ด
# Import the required library
from tkinter import *
# Create an instance of tkinter frame
win = Tk()
# Define the geometry of the window
win.geometry("600x250")
# Create a Label with Text
my_text = Label(win, text="This is a New Line Text", font=('Helvetica bold', 16))
my_text.pack(pady=15)
# Print the label text
print(my_text['text'])
win.mainloop()
ผลลัพธ์
โค้ดจะแสดง Label "This is a New Line Text" พิมพ์ได้ด้วย Print Function
