Can one use Clutter with Python 3?

1.6k Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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.

1
On

From what I gather, the answer is to use GObject rather than direct bindings, and PyGObject appears to have a Python 3 branch that apparently works - not that I have used it personally.

You might also want to see this question on using PyGObject with python 3.