如何在作業系統工具欄中更改 Tkinter 的預設標題?


Tkinter 應用程式視窗包含許多元件:視窗大小、標題、導航欄、選單欄元件等。若要配置視窗屬性,我們可以使用 Tcl/Tk 中定義的視窗管理器工具包。

若要執行視窗管理器屬性,請將命令 'wm' 與其他關鍵字一起使用。可以使用 wm_title("title") 或 title("title") 方法來配置視窗的標題。

示例

# Import the required libraries
from tkinter import *

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the window
win.geometry("700x350")

# Change the title of the window
win.wm_title("My Window")

Label(win, text="Hello, Welcome to Tutorialspoint...", font=('Calibri 24')).pack()

win.mainloop()

輸出

如果我們執行上述程式碼,則將顯示一個標題為“我的視窗”的視窗。

更新日期:2021 年 8 月 5 日

753 次瀏覽

開啟您的職業生涯

透過完成課程獲得認證

開始
廣告