Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter wm_attributes does not have all the options in Linux

I wanted to create a GUI with Tkinter in Linux (Python3.x). When I tried to execute the following: -

from tkinter import *
import tkinter


root = Tk()
root.overrideredirect(True) # Hide the cross button and that bar
root.wait_visibility(root)
root.call("wm", "attributes", ".", "-transparent", "true")



root_w = 190
root_h = 190

win_w = root.winfo_screenwidth()
win_h = root.winfo_screenheight()


root.geometry(f'{root_w}x{root_h}+{win_w - root_w - 40}+{win_h - root_h - 40}')



samplabl = Button(root, text=f"WIDTH: {win_w} HEIGHT: {win_h}", bg='#ffffff')

samplabl.pack()

root.mainloop()

This is what I get: -

Traceback (most recent call last):
  File "/home/bravo6/Desktop/Stella__Compilative/GUI/temp.py", line 8, in <module>
    root.call("wm", "attributes", ".", "-transparent", "true")
_tkinter.TclError: bad attribute "-transparent": must be -alpha, -topmost, -zoomed, -fullscreen, or -type

Looks like the wm_attribute didn't recognise the -transparent attribute... It seemed that it only works in Windows. Any idea how to get this working in Linux?

like image 220
Broteen Das Avatar asked Sep 21 '25 09:09

Broteen Das


1 Answers

There is nothing you can do. Different operating systems support different options for the window manager. As of the time I write this, these are the supported attributes for each windowing system:

All platforms: alpha, fullscreen, topmost OSX: modified, notify, titlepath, transparent Windows: disabled, toolwindow, transparentcolor X11-based systems (ie: linux, and only with some window managers) : type, zoomed

like image 166
Bryan Oakley Avatar answered Sep 22 '25 21:09

Bryan Oakley