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
793 views
in Technique[技术] by (71.8m points)

python - Remove titlebar without overrideredirect() using Tkinter?

I'm currently working with Tkinter and Python 2.7 on Linux and I was wondering if there was a way to remove the TK() window border frame and title bar without using overrideredirect(1).

I have my own close button and overrideredirect(1) presents me with a few issues that I can't accept:

I can't use attributes("-fullscreen", True) as the titlebar and borders remain.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

The window decoration is all handled by the window manager so what you are trying to do is find a way to tell the window manager to decorate your window differently from a standard application window. Tk provides overrideredirect to have the window manager completely ignore this window but we can also use Extended Window Manager Hints to declare the intended use of this toplevel window to the window manager. This is done for instance for tooltip and splashscreen windows to allow the manager to provide minimal decoration and possibly special animations.

In your case, adding a 'splash' hint should do what you want

root = tk.Tk()
root.wm_attributes('-type', 'splash')

You will need Tk 8.5 or above for this.


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

...