overlay icon indicating copy to clipboard operation
overlay copied to clipboard

Error with Linux

Open Heath123 opened this issue 4 years ago • 11 comments

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.

Heath123 avatar Jun 22 '20 20:06 Heath123

Someone else had this too: https://stackoverflow.com/questions/59085810/tkinter-tclerror-unknown-color-name-systemwindowbody

Heath123 avatar Jun 22 '20 20:06 Heath123

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

Heath123 avatar Jun 22 '20 20:06 Heath123

It would be nice if this could be fixed, though. Maybe I could PR a fix if I work it out?

Heath123 avatar Jun 22 '20 20:06 Heath123

I can try to fix some, but not immediately :P Sounds like something I can contribute to.

elvirag avatar Jun 22 '20 23:06 elvirag

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'

pl-Steve28-lq avatar Jun 23 '20 05:06 pl-Steve28-lq

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

Heath123 avatar Jun 23 '20 13:06 Heath123

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).

linxuanm avatar Jun 26 '20 04:06 linxuanm

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.

linxuanm avatar Jun 26 '20 05:06 linxuanm

Just published a fix. Please try updating your package via pip install overlay --upgrade. I'll test the compatibility with Windows later.

linxuanm avatar Jun 26 '20 05:06 linxuanm

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

Heath123 avatar Jun 26 '20 09:06 Heath123

Commenting out this fixes it when transparency is off. https://github.com/davidmaamoaix/Overlay/blob/115279eeae37009bf9f936f7eab4827ddf1b43fb/overlay/window.py#L63

Heath123 avatar Jun 26 '20 09:06 Heath123