GI Documentation - PyGObject

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# GI Documentation

This is the API provided by the toplevel “gi” package.

gi.require_version(namespace, version)
  Parameters:

    - namespace (str) – The namespace

    - version (str) – The version of the namespace which should be loaded

  Raises:

    `ValueError`

  Ensures the namespace gets loaded with the given version. If the namespace was already loaded with a different version or a different version was required previously raises ValueError.

      import gi
      gi.require_version('Gtk', '3.0')

gi.require_foreign(namespace, symbol=None)
  Parameters:

    - namespace (str) – Introspection namespace of the foreign module (e.g. “cairo”)

    - symbol (`str` or `None`) – Optional symbol typename to ensure a converter exists.

  Raises:

    `ImportError`

  Ensure the given foreign marshaling module is available and loaded.

  Example:

      import gi
      import cairo
      gi.require_foreign('cairo')
      gi.require_foreign('cairo', 'Surface')

gi.check_version(version)
  Parameters:

    version (tuple) – A version tuple

  Raises:

    `ValueError`

  Compares the passed in version tuple with the gi version and does nothing if gi version is the same or newer. Otherwise raises ValueError.

gi.get_required_version(namespace)
  Returns:

    The version successfully required previously by `gi.require_version()` or `None`

  Return type:

    str or `None`

gi.version_info = (3, 18, 1)

  The version of PyGObject

class gi.PyGIDeprecationWarning

  The warning class used for deprecations in PyGObject and the included Python overrides. It inherits from DeprecationWarning and is hidden by default.

class gi.PyGIWarning

  Like `gi.PyGIDeprecationWarning` but visible by default.