问题描述
我想删除使用 tkinter
制作的应用程序的窗口边框.
I want to remove window border of my application made using tkinter
.
我已经使用了overrideredirect(1)
,但它并没有让我满意:它按照我的意愿移除了窗口边框,但同时也移除了任务栏上的图标.
I already used overrideredirect(1)
, but it didn't satisfy me: it removed the window border as I wanted, but it also removed the icon on the task bar.
我怎样才能删除窗口边框?
How can I just remove the window border?
推荐答案
我想这就是您要的.我不知道您是否可以在不使用 Toplevel
的情况下执行此操作,但这里有一个小示例,说明您可以执行哪些操作来移除窗口边框并将图标保留在任务栏中.
I think this is what you were asking for. I don't know if you can do this without using Toplevel
or not, but here's a small example of what you could do to remove the window border and keep the icon in the taskbar.
import tkinter as tk
root = tk.Tk()
root.attributes('-alpha', 0.0) #For icon
#root.lower()
root.iconify()
window = tk.Toplevel(root)
window.geometry("100x100") #Whatever size
window.overrideredirect(1) #Remove border
#window.attributes('-topmost', 1)
#Whatever buttons, etc
close = tk.Button(window, text = "Close Window", command = lambda: root.destroy())
close.pack(fill = tk.BOTH, expand = 1)
window.mainloop()
然后你可以添加按钮,标签,任何你想要的window
You could then add buttons, labels, whatever you want to window
这篇关于如何仅删除窗口边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!