python-3.xclutterpython-bindings

Can one use Clutter with Python 3?


Are there Python 3 bindings for Clutter? If so, how can I get them and use them?


Solution

  • As stated by Lattyware, the way to use Clutter in Python 3 is by installing "GObject introspection" data and allowing GObject to dynamically generate the bindings to the original C library.

    On Ubuntu 11.10, install both Python 3 GObject and the GObject introspection data for clutter:

    sudo apt-get install python3-gobject gir1.2-clutter-1.0
    

    On Ubuntu 12.04 and later, the python3-gobject package has been renamed to python3-gi:

    sudo apt-get install python3-gi gir1.2-clutter-1.0
    

    If you want to install the GTK+ Clutter library:

    sudo apt-get install python3-gi gir1.2-gtkclutter-1.0
    

    If using a virtualenv virtual Python environment, use the following command, which allows Python to find the GObject introspection libraries:

    virtualenv env -p python3 --system-site-packages
    

    To use Clutter or GtkClutter in Python 3:

    from gi.repository import Clutter
    from gi.repository import GtkClutter
    

    The package gi.repository is a special package which dynamically generates these Python classes.