如何在 Tkinter 中從標題欄中移除圖示?


若要移除 Tkinter 視窗的預設圖示,我們可以透過指定屬性型別使用 wm_attributes('type', 'value') 方法。在以下示例中,我們將使用 '-toolwindow'(一個布林值,用於移除與應用程式標題欄關聯的圖示)。

示例

#Import the tkinter library
from tkinter import *

#Create an instance of tkinter frame
win = Tk()
win.geometry("700x350")

#Create a Label to print the Name
label= Label(win, text="This is a New Line Text", font= ('Helvetica 14 bold'), foreground= "red3")
label.pack()

win.wm_attributes('-toolwindow', 'True')
win.mainloop()

輸出

當我們執行以上程式碼時,它將顯示一個 Tkinter 視窗,且標題欄中沒有它的預設圖示。

更新時間:2021 年 5 月 25 日

4K+ 次瀏覽

開啟你的 職業生涯

透過完成課程,取得資格認證

開始學習
廣告
© . All rights reserved.