Tkinter สร้างหน้าต่างหรือเฟรมที่ปรากฏหลังจากรันโปรแกรม เนื่องจากฟังก์ชันและโมดูลทั้งหมดใน Tkinter เป็นอิสระต่อกัน เราจึงสามารถใช้ฟังก์ชันเฉพาะเพื่อปรับแต่งแอตทริบิวต์ของหน้าต่างได้
Tkinter สร้าง Root window เริ่มต้นสำหรับทุกแอปพลิเคชัน เพื่อปรับแต่งหรือแก้ไข Title เริ่มต้นของ Tkinter window เราสามารถใช้เมธอดต่อไปนี้:
title(text="your title")
ลองสร้างหน้าต่างโดยสร้างอ็อบเจกต์ของ Tkinter frame และแก้ไข Title ของหน้าต่างหรือเฟรม
ตัวอย่าง
# Import the library
from tkinter import *
# Create an instance of window
win = Tk()
# Set the geometry of the window
win.geometry("700x400")
# Set the title of the window
win.title("tutorialspoint.com")
# Create a label if needed
Label(win, text="The Title is tutorialspoint.com", font=('Helvetica bold', 20), fg="green").pack(pady=20)
# Keep running the window or frame
win.mainloop()
ผลลัพธ์
โค้ด Python ข้างต้นจะตั้ง Title เป็น tutorialspoint.com
