如何在 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.