overlay
overlay copied to clipboard
Error with Linux
When using this code:
import tkinter as tk
from overlay import Window
win_0 = Window()
label_0 = tk.Label(win_0.root, text="Window_0")
label_0.pack()
win_1 = Window()
label_1 = tk.Label(win_1.root, text="Window_1")
label_1.pack()
Window.launch()
I get this error:
Traceback (most recent call last):
File "/home/heath/overlaytest.py", line 4, in <module>
win_0 = Window()
File "/home/heath/.local/lib/python3.8/site-packages/overlay/window.py", line 42, in __init__
self.transparent = kwargs.get('transparent', False)
File "/home/heath/.local/lib/python3.8/site-packages/overlay/window.py", line 125, in transparent
self._root.config(bg=bg)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1637, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1627, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown color name "systemWindowBody"
A small grey square also appears in the top-left corner of the screen.
Someone else had this too: https://stackoverflow.com/questions/59085810/tkinter-tclerror-unknown-color-name-systemwindowbody
Just realised this is a duplicate of #1, but this is Linux so I'll leave it open just in case? You can close it
It would be nice if this could be fixed, though. Maybe I could PR a fix if I work it out?
I can try to fix some, but not immediately :P Sounds like something I can contribute to.
I had similar issues on Windows. Just Copy the Window.py in here or find it in package file and fix color name that makes Error I changed the color name 'black' and 'white' instead of 'SystemTransparent' and 'SystemWindowBody'
I changed the color name 'black' and 'white' instead of 'SystemTransparent' and 'SystemWindowBody'
No transparent windows then... That might be impossible with tkinter on Linux
Hi. It seems like many people would like this to work on Windows and Linux. I'll redo the code recently and try to fix the problem (should be a quick fix though).
Added a quick fix to use white instead of grabbing for system color (which is a Mac OS specific attribute). Will release to Pypi after a few local tests.
Just published a fix. Please try updating your package via pip install overlay --upgrade
.
I'll test the compatibility with Windows later.
Thank you, but this still has errors:
import tkinter as tk
from overlay import Window
win_0 = Window()
label_0 = tk.Label(win_0.root, text="Window_0")
label_0.pack()
win_1 = Window()
label_1 = tk.Label(win_1.root, text="Window_1")
label_1.pack()
Window.launch()
Output:
Traceback (most recent call last):
File "/home/heath/overlaytest.py", line 4, in <module>
win_0 = Window()
File "/home/heath/.local/lib/python3.8/site-packages/overlay/window.py", line 63, in __init__
self._root.wm_attributes('-transparent', True)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1967, in wm_attributes
return self.tk.call(args)
_tkinter.TclError: bad attribute "-transparent": must be -alpha, -topmost, -zoomed, -fullscreen, or -type
With transparency on:
import tkinter as tk
from overlay import Window
win_0 = Window(transparent = True)
label_0 = tk.Label(win_0.root, text="Window_0")
label_0.pack()
win_1 = Window()
label_1 = tk.Label(win_1.root, text="Window_1")
label_1.pack()
Window.launch()
Output:
Traceback (most recent call last):
File "/home/heath/overlaytest.py", line 4, in <module>
win_0 = Window(transparent = True)
File "/home/heath/.local/lib/python3.8/site-packages/overlay/window.py", line 44, in __init__
self.transparent = kwargs.get('transparent', False)
File "/home/heath/.local/lib/python3.8/site-packages/overlay/window.py", line 156, in transparent
self._root.config(bg=bg)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1637, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.8/tkinter/__init__.py", line 1627, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown color name "systemTransparent"
It seems like transparency might not be possible on Linux
Commenting out this fixes it when transparency is off. https://github.com/davidmaamoaix/Overlay/blob/115279eeae37009bf9f936f7eab4827ddf1b43fb/overlay/window.py#L63