Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีสร้างแอปพลิเคชันเต็มหน้าจอไม่มีขอบ (Borderless) ด้วย Tkinter Python 3

เพื่อทำให้หน้าต่าง Tkinter เป็นเต็มหน้าจอและไม่มีขอบ สามารถใช้เมธอด attributes('-fullscreen', True) ได้

วิธีอีกวิธีคือใช้ overrideredirect(True) ซึ่งจะซ่อนแถบหัวเรื่องและขอบหน้าต่าง แต่ต้องจัดการปิดโปรแกรมเอง

ตัวอย่างโค้ด

# Import the required Libraries
from tkinter import *

# Create an instance of Tkinter frame
win = Tk()

# Set the Geometry
win.geometry("750x250")

# Full Screen Window
win.attributes('-fullscreen', True)

def quit_win():
    win.destroy()

# Create a Quit Button
button = Button(win, text="Quit", font=('Comic Sans', 13, 'bold'), command=quit_win)
button.pack(pady=20)

win.mainloop()

ผลลัพธ์

โปรแกรมจะแสดงหน้าต่างเต็มจอ ไม่มีแถบควบคุม สามารถปิดได้โดยกดปุ่ม Quit หรือ Alt+F4

วิธีสร้างแอปพลิเคชันเต็มหน้าจอไม่มีขอบ (Borderless) ด้วย Tkinter Python 3