如何在 Tkinter 中顯示全屏模式?
Tkinter 預設按應用程式視窗大小顯示。但是,我們可以使用 attributes('fullscreen', True) 方法顯示一個全屏視窗。該方法通常用於為 tkinter 視窗指定 transparentcolor、 alpha、disabled、fullscreen、toolwindow和 topmost等屬性。
示例
#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 鍵可以關閉該視窗。
廣告