Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
688 views
in Technique[技术] by (71.8m points)

python - Making Tkinter windows show up in the taskbar

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.

This is for Windows 7.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...