Tkinter 类中 title() 和 wm_title() 方法之间的差别


Tkinter 有确定的类层次结构,包含许多函数和内置方法。在创建应用程序时,我们使用这些函数来构建组件的结构。Wm 类代表mixin类,提供许多内置函数和方法。

方法wm_title() 用于更改 tkinter 窗口的标题。但是,我们也可以使用win.title()方法。通常,wm 类提供许多让我们与窗口服务进行通信的方法。

示例

# 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")
win.wm_title("This is the Title")

# Add A label widget
Label(win, text="Welcome to TutorialsPoint✨ \n" "You are browsing the best resource for Online Education.", font=('Aerial 18 italic')).place(x=50, y=150)

win.mainloop()

输出

运行上述代码以显示一个窗口,该窗口将包含一些标签文本小部件。

更新于: 19-6-2021

897 次浏览

开启你的 职业生涯

完成课程,获得认证

开始
广告
© . All rights reserved.