Python Bindings for EFL

TOC?

About

Python bindings live under trunk/BINDINGS/python and are actively maintained. They might not cover 100% of C features, but covers enough to enable lots of eye candy applications such as  Canola2 Media Player,  OpenMoko's Paroli, Edje Editor, Arduino-EFL Ardy and others.

The commonly used EFL libraries have python bindings. Some of the rarely used features are not mapped. Written by experienced Python developers, it tries to be as "Pythonic" as possible, while exposing API similar to C to help knowledge and documentation reuse.

Supported Libraries


Lib Category Library Function Description Coverage (*)
Core Evas Graphics Canvas object and rendering Good, Textblock is barebones
Core Edje Graphics Higher level graphical object abstraction Good
Core Eina Utility Data structures and utilities ?
Core Eet Utility Data encoding and decoding to and from files or memory ?
Core Ecore System Core loop and OS interfacing libraries Good (ecore, ecore.evas), file/imf/x are barebones
Core Efreet System Freedesktop.org standards compliance ?
Core E_Dbus System DBus usage convenience library Barebones (links python-dbus to main loop, everything else is left to python-dbus)
Core Eeze System UDev access library ?
Core? Embryo Utility? Embedded Small Interpreter ?
Extra Elementary Graphics Widget set library Good (less used widgets missing)
Extra Emotion Graphics Media playback integration library Full
Extra Eio Utility Efficient I/O over file system (cp, mv, rm, stat, ls...) ?
Extra Ethumb Utility Creates thumbnail images, videos and documents Full (client)
Extra Evil? System Windows compatibility layer ?
Extra EWebKit Web Web runtime and browser core ?


(*) Coverage terms:

  • Barebones - just started
  • Essential - covers the minimum
  • Good - covers what most developers would use
  • Full - everything has bindings

Details

Consider the following C code and the Python implementations:

Evas_Object *my_func(Evas *canvas)
{
   Evas_Coord x, y, w, h;
   Evas_Object *rect = evas_object_rectangle_add(canvas);
   evas_object_move(rect, 100, 200);
   evas_object_resize(rect, 50, 60);
   evas_object_geometry_get(rect, &x, &y, &w, &h);
   printf("%d %d %d %d\n", x, y, w, h);
   return rect;
}
def my_func(canvas):
   rect = evas.Rectangle(canvas)
   rect.move(100, 200)
   rect.resize(50, 60)
   print rect.geometry_get()
   return rect
def my_func(canvas):
   rect = evas.Rectangle(canvas, geometry=(100, 200, 50, 60))
   print rect.geometry
   return rect

As seen, we tried to provide C-like api, but also provide excellent Python features, such as properties, constructor parameters and other things that make sense, like geometry_set(), pos_get() and size_get() that are not present in C. Take a look at  documentation for more!

Getting ready to use it

Code lives in SVN under trunk/BINDINGS/python. It was written using  Cython tool, so it's required to build from SVN. These are the instructions for Debian based systems:

# Before start: be sure to have EFL development files installed, either
# from SVN, tarballs or binary packages that provides pkg-config (*.pc) files
# as well as headers and development assets.

# get dependencies (varies from system to system):
sudo apt-get install build-essential pkg-config cython

svn checkout http://svn.enlightenment.org/svn/e/trunk/BINDINGS/python  python-efl
cd python-efl

# 1. install to /usr (needs root):
./autogen.sh --prefix=/usr ; make ; sudo make install

# 2. install to $HOME/usr (needs {{{$PYTHONPATH}}} set):
./autogen.sh --prefix=$HOME/usr ; make ; make install

# please note that some cython versions (< 0.12?) have problems with CFLAGS="-O0". So compile the bindings with CFLAGS="-O2" if you get strage segfaults.

Learn it

API documentation is available at  http://staff.get-e.org/~barbieri/python-efl-api/, it is automatically generated using  epydoc, you can generate it yourself! As recommended by Python, documentation is built-in into code with pydoc strings, so from interpreters one can call help(evas.Canvas) or on any other class, function, method or object (after all, these are all objects in python ;-P) to get its documentation.

Walk through tutorials: to be done

Catches, tips and tricks: see Python/Catches, be sure to read it and not fall into traps!