phillipberndt/fakexrandr

Ubuntu 22.04 fakexrandr-manage crashes: 'gi.repository.Gtk' object has no attribute 'HBox'

p0pit0 opened this issue · 3 comments

Ubuntu 22.04 fakexrandr-manage crashes

fakexrandr-manage
/usr/bin/fakexrandr-manage:27: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '4.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gdk
Traceback (most recent call last):
File "/usr/bin/fakexrandr-manage", line 318, in
class ConfigurationWidget(Gtk.HBox):
File "/usr/lib/python3/dist-packages/gi/overrides/init.py", line 32, in getattr
return getattr(self._introspection_module, name)
File "/usr/lib/python3/dist-packages/gi/module.py", line 123, in getattr
raise AttributeError("%r object has no attribute %r" % (
AttributeError: 'gi.repository.Gtk' object has no attribute 'HBox'

Same identical issue with Fedora 36 (Mate/Marco windows manager)

fakexrandr-manage 
/usr/bin/fakexrandr-manage:37: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '4.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk, Gdk
Traceback (most recent call last):
  File "/usr/bin/fakexrandr-manage", line 328, in <module>
    class ConfigurationWidget(Gtk.HBox):
  File "/usr/lib/python3.10/site-packages/gi/overrides/__init__.py", line 32, in __getattr__
    return getattr(self._introspection_module, name)
  File "/usr/lib64/python3.10/site-packages/gi/module.py", line 126, in __getattr__
    raise AttributeError("%r object has no attribute %r" % (
AttributeError: 'gi.repository.Gtk' object has no attribute 'HBox'

Does adding import gi; gi.require_version('Gtk', '3.0') to the top of the script, straight before the first other Import, suffice to fix this?

Thanks for the fast reply.

Yes, It works for me.
Adding import gi; gi.require_version('Gtk', '3.0'), just after from __future__ import print_function, in fakexrandr-manage script

Thanks again.