[英]Why title does not change in tkinter?
from tkinter import *
import win32api
from tkinter import filedialog
from mood import Dominant
from form import Assessment
import json
ca=Assessment()
window=Toplevel()
window.withdraw()
window.title("Analysis")
When I try to change title on the window still the title appears as "tk".当我尝试更改 window 上的标题时,标题仍显示为“tk”。 I saw some answers but they were related OOP in the main window I could not change the title.
我看到了一些答案,但它们与主要 window 中的 OOP 相关,我无法更改标题。
You changed the title of the hidden Toplevel()
(since you have executed window.withdraw()
), not the visible root window (created implicitly).您更改了隐藏的
Toplevel()
的标题(因为您已经执行window.withdraw()
),而不是可见的根 window(隐式创建)。
Use window.master.title("Analysis")
to change the title of the visible root window.使用
window.master.title("Analysis")
更改可见根 window 的标题。
Or create the root window explicitly and change its title as below:或者显式创建根 window 并更改其标题,如下所示:
import tkinter as tk
root = tk.Tk()
window=tk.Toplevel()
window.withdraw()
root.title("Analysis")
root.mainloop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.