Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove titlebar without overrideredirect() using Tkinter?

Tags:

python

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:

  • GUI always on top
  • can't iconify then deiconify properly
  • no keyboard input so can't type into fields (see python tkinter overrideredirect; cannot receive keystrokes (Linux))

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

like image 592
D'Arcy Avatar asked Sep 16 '16 10:09

D'Arcy


People also ask

How do I remove the title bar in Python?

Build A Paint Program With TKinter and Python To remove the title bar of a Tkinter window, we can use wm_attributes('type', 'value') method by specifying the type of property. In the following example, we will use 'fullscreen', a Boolean value that removes the title bar of the window.

How do I close tkinter toplevel?

For a particular application, if we have defined a Toplevel window, then we can close it using the destroy() method.

How do I close a tkinter window without ending program?

Creating an application using tkinter is easy but sometimes, it becomes difficult to close the window or the frame without closing it through the button on the title bar. In such cases, we can use the . destroy() method to close the window.

What does withdraw () tkinter do?

Tkinter withdraw method hides the window without destroying it internally. It is similar to the iconify method that turns a window into a small icon. Let us suppose we want to reveal the hidden window during the execution of an application then we can use deiconify() method.


2 Answers

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.

like image 197
patthoyts Avatar answered Sep 28 '22 22:09

patthoyts


You must give your root window name before your command.

Like this:

from tkinter import *

root=Tk()
root.wm_attributes('-fullscreen','true')
root.mainloop()
like image 31
abhi krishnan Avatar answered Sep 28 '22 20:09

abhi krishnan