Search code examples
pythongtk3gnomepython-keyring

Use gnomekeyring module with Python and GTK3 on Ubuntu 14.04


I am using Linux Mint 17, based on Ubuntu 14.04

I have installed:

  • python-gnomekeyring 2.3.2#
  • python-gi 3.12
  • python-gtk2 2.24

I have the following script:

#!/usr/bin/python

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import gnomekeyring

But I get an error:

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed import gobject._gobject

what can I do to fix thix?

edit: Get attributes of GnomeKeyring key with Python 2.7 GTK3 on Ubuntu 14.04


Solution

  • python-gnomekeyring uses Gtk+2 and cannot be used in the same process as Gtk+3.

    You should be able to use GnomeKeyring-1.0 from gi.repository:

    import gi
    gi.require_version('Gtk', '3.0')
    gi.require_version('GnomeKeyring', '1.0')
    
    from gi.repository import Gtk, GnomeKeyring
    

    As oxidworks notes in the comments, current GnomeKeyring has marked all of it's API deprecated: libsecrets "Secret" D-Bus API (which on GNOME is provided by GNOME keyring) should be able to do the same things.

    There's a Python API reference but the canonical reference has some python examples as well as advice on migrating from gnome-keyring -- but be aware that the latter will mostly talk about the C API.