1

I want to make a borderless widget with tkinter that lets the user decide if they want the application to show on top of other programs or not. I'm aware that in order to remove the borders and the toolbar I can use the method root.overrideredirect(True), but this also makes the window topmost automatically, as it makes the window manager ignore the widget. Because of this, the root.attributes("-topmost",False) and root.wm_attributes("-topmost", False) command don't work.

Is there a way to achieve what I need? For example, another method to hide the window manager decorations or some other way to hide/restore the widget when it loses the focus? By the way, I'm using Linux Mint 20.2 Cinnamon v5.0.5 with Python 3.8.10.

from tkinter import *
root = Tk()
root.overrideredirect(True)      
root.resizable(False, False)
root.geometry("420x100")
root.attributes("-topmost", False)
#root.wm_attributes("-topmost", False)
exitbtn = Button(root, text='Exit',command=root.destroy)
exitbtn.pack(side=BOTTOM)
root.mainloop()

EDIT: After some search, I've found that root.wm_attributes('-type','splash') works exactly as I want. But it seems that this will only work on Linux. How could I achieve that on Windows?

nikored
  • 11
  • 2
  • 1
    On Linux it makes sense to get in touch with the Xlib. – Thingamabobs Aug 17 '21 at 04:54
  • @Atlas435 thanks, I will look into it but I would rather use something that works on Windows too. – nikored Aug 17 '21 at 18:18
  • *Portability: The library will be usable on (almost) any computer which have Python installed. A C interface could be problematic to port to non-Unix systems, such as MS Windows or OpenVMS.*https://github.com/python-xlib/python-xlib – Thingamabobs Aug 17 '21 at 19:00

1 Answers1

0

I had the same question and this worked for me:

Tkinter, Windows: How to view window in windows task bar which has no title bar?

PS: I'm new here so I cannot comment.

Edit: It's for Windows I think. I haven't tried on Linux yet.

IJ_123
  • 457
  • 6
  • 13