parkouss / pyewmh

An implementation of EWMH (Extended Window Manager Hints) for python, based on Xlib.
GNU Lesser General Public License v3.0
40 stars 15 forks source link

[BUG] Missing handling of case where no property is obtained within getWmPid #22

Open omlins opened 1 year ago

omlins commented 1 year ago

MWE:

import PySimpleGUI
import pywinctl

PySimpleGUI.popup('just say it!', 
        no_titlebar = False,
        keep_on_top = True,
        title = "dummy title",
        non_blocking = True,
        )

pywinctl.getAllAppsWindowsTitles()

Resulting error:

$ /bin/python3 /home/omlins/tmpwdir/juliadev/JustSayIt/src/gui_test2.py
Traceback (most recent call last):
  File "/home/omlins/tmpwdir/juliadev/JustSayIt/src/gui_test2.py", line 11, in <module>
    pywinctl.getAllAppsWindowsTitles()
  File "/home/omlins/.local/lib/python3.10/site-packages/pywinctl/_pywinctl_linux.py", line 235, in getAllAppsWindowsTitles
    appName = win.getAppName()
  File "/home/omlins/.local/lib/python3.10/site-packages/pywinctl/_pywinctl_linux.py", line 763, in getAppName
    pid = EWMH.getWmPid(self._hWnd)
  File "/home/omlins/.local/lib/python3.10/site-packages/ewmh/ewmh.py", line 400, in getWmPid
    return self._getProperty('_NET_WM_PID', win)[0]
TypeError: 'NoneType' object is not subscriptable

NOTE: The error occurred also when having a window open created with turtle. Thus, the problem does not only occur with PySimpleGUI, but probably with all GUIs that underneath rely on tkinter.

MestreLion commented 1 year ago

This was already fixed in acd586975622dd06fbb1c26e32bc0b1624daae59 . Unfortunately no new tag or released since then, here on Github or Pypi.

A workaround, if installing using pip, is pointing it here instead of Pypi:

$ pip install 'ewmh @ git+https://github.com/parkouss/pyewmh'