如何在 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 窗口,且标题栏中没有它的默认图标。
![]()
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP