如何在作業系統工具欄中更改 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()
輸出
如果我們執行上述程式碼,則將顯示一個標題為“我的視窗”的視窗。
廣告