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

จะแสดงโหมดเต็มหน้าจอบน Tkinter ได้อย่างไร?


Tkinter แสดงหน้าต่างแอปพลิเคชันตามขนาดเริ่มต้น อย่างไรก็ตาม เราสามารถแสดงหน้าต่างแบบเต็มหน้าจอได้โดยใช้ attributes('fullscreen', True) กระบวนการ. โดยทั่วไปวิธีการนี้ใช้สำหรับกำหนดหน้าต่าง tkinter ที่มีคุณสมบัติเช่น transparentcolor , อัลฟ่า, ปิดใช้งาน, เต็มหน้าจอ, หน้าต่างเครื่องมือ และ บนสุด .

ตัวอย่าง

#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= "Hello World!", font=('Times New Roman bold',20))
label.pack(padx=10, pady=10)

#Create a fullscreen window
win.attributes('-fullscreen', True)

win.mainloop()

ผลลัพธ์

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

จะแสดงโหมดเต็มหน้าจอบน Tkinter ได้อย่างไร?