Tkinter สร้างหน้าต่างหรือเฟรมที่ปรากฏขึ้นหลังจากรันโปรแกรม เนื่องจากฟังก์ชันและโมดูลทั้งหมดใน Tkinter มีความเป็นอิสระ เราจึงสามารถใช้ฟังก์ชันเฉพาะเพื่อปรับแต่งแอตทริบิวต์ของหน้าต่างได้โดยเฉพาะ
Tkinter สร้างหน้าต่างรูทเริ่มต้นสำหรับทุกแอปพลิเคชัน ในการปรับแต่งหรือแก้ไขชื่อเริ่มต้นของหน้าต่าง Tkinter เราสามารถใช้วิธีการดังต่อไปนี้
title(text= “your title”)
ให้เราสร้างหน้าต่างโดยเริ่มต้นวัตถุของเฟรม Tkinter และแก้ไขชื่อหน้าต่างหรือเฟรม
ตัวอย่าง
#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 ด้านบนจะตั้งชื่อเป็น tutorialspoint.com
