This change makes the gtk and appindicator backends behave better when the gi module is present but the necessary namespace is not. EG, on Lubuntu, the gtk backend works but without this change, pystray crashes because gi is available but the AppIndicator3 namespace is not.
Traceback (most recent call last):
File "testapp.py", line 1, in <module>
import pystray
File "/home/dschep/code/me/pystray-test/venv/lib/python3.8/site-packages/pystray/__init__.py", line 48, in <module>
Icon = backend().Icon
File "/home/dschep/code/me/pystray-test/venv/lib/python3.8/site-packages/pystray/__init__.py", line 40, in backend
return importlib.import_module(__package__ + '._' + module)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/dschep/code/me/pystray-test/venv/lib/python3.8/site-packages/pystray/_appindicator.py", line 27, in <module>
gi.require_version('AppIndicator3', '0.1')
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AppIndicator3 not available
It of course works if you specify PYSTRAY_BACKEND, but the default behaviour should be as user friendly & robust as possible.
This change makes the
gtk
andappindicator
backends behave better when thegi
module is present but the necessary namespace is not. EG, on Lubuntu, the gtk backend works but without this change,pystray
crashes becausegi
is available but theAppIndicator3
namespace is not.It of course works if you specify
PYSTRAY_BACKEND
, but the default behaviour should be as user friendly & robust as possible.