Closed elibroftw closed 2 years ago
Actually pystray doesn't work at all on Ubuntu Gnome
import pystray
icon = pystray.Icon('test name')
Traceback (most recent call last):
File "/home/maste/.local/lib/python3.8/site-packages/pystray/_appindicator.py", line 23, 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
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pystray
File "/home/maste/.local/lib/python3.8/site-packages/pystray/__init__.py", line 62, in <module>
Icon = backend().Icon
File "/home/maste/.local/lib/python3.8/site-packages/pystray/__init__.py", line 54, in backend
return candidate()
File "/home/maste/.local/lib/python3.8/site-packages/pystray/__init__.py", line 26, in appindicator
from . import _appindicator as backend; return backend
File "/home/maste/.local/lib/python3.8/site-packages/pystray/_appindicator.py", line 26, in <module>
gi.require_version('AyatanaAppIndicator3', '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 AyatanaAppIndicator3 not available
With the pgi fix,
File "/home/fortanix/Documents/GitHub/music-caster/src/music_caster.py", line 106, in system_tray
tray = pystray.Icon('Music Caster SystemTray', unfilled_icon, title='Music Caster [LOADING]')
File "/home/fortanix/.local/lib/python3.10/site-packages/pystray/_gtk.py", line 36, in __init__
self._status_icon.connect(
File "/home/fortanix/.local/lib/python3.10/site-packages/pgi/obj.py", line 156, in connect
return self.__connect(0, detailed_signal, handler, *args)
File "/home/fortanix/.local/lib/python3.10/site-packages/pgi/obj.py", line 118, in __connect
cb = generate_signal_callback(info)(_add_self)
File "/home/fortanix/.local/lib/python3.10/site-packages/pgi/codegen/siggen.py", line 153, in generate_signal_callback
cb_func = _generate_signal_callback(backend, info, args, arg_types)
File "/home/fortanix/.local/lib/python3.10/site-packages/pgi/codegen/siggen.py", line 101, in _generate_signal_callback
cls = get_cbarg_class(type_)
File "/home/fortanix/.local/lib/python3.10/site-packages/pgi/codegen/cbargs.py", line 149, in get_cbarg_class
raise NotImplementedError(
NotImplementedError: 'UINT32' signal argument not implemented
Thank you for your report.
I run the latest version of Ubuntu on my computer, and pystray does work. I may have installed the required libraries manually a long time ago. Do you have any of the packages libappindicator*
installed? If not, does installing libappindicator3-1
fix your problem?
It works fine if I use the built in Python version but I can't seem to get it to work with Python3.10.
Since GI-support appears to be pretty tied to the system Python installation, and pgi does not appear to be functional yet. When looking at the list of issues for pgi, I notice several similar ones.
I think going forward with this will will have to wait until your issue on pgi is resolved.
Yeah it's fine
It was hard to make it work, but per pip-installation (!) of PyGObject from https://pygobject.readthedocs.io/en/latest/getting_started.html#ubuntu-getting-started help me for non-system python from pyenv (3.9.10)
@dmtea, thank you for the suggestion.
I managed to get pystray using AppIndicator up and running in a virtualenv by installing PyGObject. Unfortunately, no wheels are provided on PyPi and it must thus be built locally when installing, requiring installation of at least libgirepository1.0-dev and libcairo-dev.
I will update the documentation with this information.
Currently, if developers want to use a newer version of python on Ubuntu, the gi import will fail. But there is a
pgi
module. Therefore allimport gi
should be replaced with