servabat
servabat

Reputation: 376

GUI without WM frame

Is there a python library that allows you to create a GUI without the window manager (and equivalent under MS Windows) frame thing, and allow to set the window top-most (like over all other windows) ?

I've been looking on Internet but I'm obviously missing the right keywords.

Upvotes: 2

Views: 1320

Answers (1)

en_Knight
en_Knight

Reputation: 5381

Yup. Tkinter, or "tkinter" in python3. It's included in standard python distributions

Removing the Window Manager

The method

root.overrideredirect(True)

Removes the borders and manager. Setting the flag indicates to the manager that you don't want the widget to be managed. You can look at ttk, an extension to tkinter commonly included (in Python3 it's tkinter.ttk) if you don't want to completely remove the border, but just pick a different style.

Setting the TopMost Attribute

The method

root.wm_attributes("-topmost", 1)

Will put it at the top of the screen Combined, these will give you the desired behavior. You can then use other tkinter frames to decorate the widget as you please, i.e., add custom borders or close/minus buttons that would normally be included in the manager.

Resources

See this, e.g. for applying the topmost attribute

Make a tkinter window appear over all other windows

From Effbot about "overridedirect" (http://effbot.org/tkinterbook/wm.htm):

Sets or gets the override redirect flag. If non-zero, this prevents the window manager from decorating the window. In other words, the window will not have a title or a border, and it cannot be moved or closed via ordinary means.

Note: These functions can only be applied to the root window (Tk instance) or another Toplevel instance.

Upvotes: 5

Related Questions