| 1 |
.. _guide-api: |
| 2 |
|
| 3 |
================ |
| 4 |
GI Documentation |
| 5 |
================ |
| 6 |
|
| 7 |
This is the API provided by the toplevel "gi" package. |
| 8 |
|
| 9 |
|
| 10 |
.. function:: gi.require_version(namespace, version) |
| 11 |
|
| 12 |
:param str namespace: The namespace |
| 13 |
:param str version: The version of the namespace which should be loaded |
| 14 |
:raises: ..py:exception:: ValueError |
| 15 |
|
| 16 |
Ensures the namespace gets loaded with the given version. If the namespace |
| 17 |
was already loaded with a different version or a different version was |
| 18 |
required previously raises ValueError. |
| 19 |
|
| 20 |
:: |
| 21 |
|
| 22 |
import gi |
| 23 |
gi.require_version('Gtk', '3.0') |
| 24 |
|
| 25 |
|
| 26 |
.. function:: gi.require_foreign(namespace, symbol=None) |
| 27 |
|
| 28 |
:param str namespace: |
| 29 |
Introspection namespace of the foreign module (e.g. "cairo") |
| 30 |
:param symbol: |
| 31 |
Optional symbol typename to ensure a converter exists. |
| 32 |
:type symbol: :obj:`str` or :obj:`None` |
| 33 |
:raises: ..py:exception:: ImportError |
| 34 |
|
| 35 |
Ensure the given foreign marshaling module is available and loaded. |
| 36 |
|
| 37 |
Example: |
| 38 |
|
| 39 |
.. code-block:: python |
| 40 |
|
| 41 |
import gi |
| 42 |
import cairo |
| 43 |
gi.require_foreign('cairo') |
| 44 |
gi.require_foreign('cairo', 'Surface') |
| 45 |
|
| 46 |
|
| 47 |
.. function:: gi.check_version(version) |
| 48 |
|
| 49 |
:param tuple version: A version tuple |
| 50 |
:raises: ..py:exception:: ValueError |
| 51 |
|
| 52 |
Compares the passed in version tuple with the gi version and does nothing |
| 53 |
if gi version is the same or newer. Otherwise raises ValueError. |
| 54 |
|
| 55 |
|
| 56 |
.. function:: gi.get_required_version(namespace) |
| 57 |
|
| 58 |
:returns: The version successfully required previously by :func:`gi.require_version` or :obj:`None` |
| 59 |
:rtype: str or :obj:`None` |
| 60 |
|
| 61 |
|
| 62 |
.. data:: gi.version_info |
| 63 |
:annotation: = (3, 18, 1) |
| 64 |
|
| 65 |
The version of PyGObject |
| 66 |
|
| 67 |
|
| 68 |
.. class:: gi.PyGIDeprecationWarning |
| 69 |
|
| 70 |
The warning class used for deprecations in PyGObject and the included |
| 71 |
Python overrides. It inherits from DeprecationWarning and is hidden |
| 72 |
by default. |
| 73 |
|
| 74 |
|
| 75 |
.. class:: gi.PyGIWarning |
| 76 |
|
| 77 |
Like :class:`gi.PyGIDeprecationWarning` but visible by default. |