本文介绍了使 Tkinter 窗口显示在任务栏中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让我的程序显示在任务栏中,但仍然没有传统的 Windows 边框.我该怎么办?我知道 self.overrideredirect(1),但是这会从任务栏中删除我的程序.
I want a program of mine to show up in the taskbar, but still not have the traditional windows boarder. How can I go about this? I know of self.overrideredirect(1), however this removes my program from the taskbar.
这适用于 Windows 7.
This is for Windows 7.
推荐答案
我不认为这是正确"的方法,但看看这是否适合您:
I make no claim about this being the 'correct' way to do it, but see if this works for you:
try:
from tkinter import *
except ImportError:
from Tkinter import *
class NewRoot(Tk):
def __init__(self):
Tk.__init__(self)
self.attributes('-alpha', 0.0)
class MyMain(Toplevel):
def __init__(self, master):
Toplevel.__init__(self, master)
self.overrideredirect(1)
self.attributes('-topmost', 1)
self.geometry('+100+100')
self.bind('<ButtonRelease-3>', self.on_close) #right-click to get out
def on_close(self, event):
self.master.destroy()
if __name__ == '__main__':
root = NewRoot()
root.lower()
root.iconify()
root.title('Spam 2.0')
app = MyMain(root)
app.mainloop()
这篇关于使 Tkinter 窗口显示在任务栏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!