Unity Places – now with 100% More Python

Some may have seen that I was pimping my session Rocking out with libunity at the Ubuntu Developer Week promising a surprise. The surprise was that I had a fully working Unity Place implementation all in Python. If you want you can peruse the full log from the IRC session, it might be helpful if you want to try this out yourself.

Hopefully unsurprisingly – the Python integration is all done with PyGI, the Python bindings for GObject Introspection. I must admit that it was a slight challenge getting everything working smoothly, but we’re there now. I want to give mad props to the pygobject- and the GObject Introspection teams. Without their enduring help we wouldn’t have got to this point. So thanks guys, you rock!

So lets get down to business. How does this work, what does it look like?

Setting up a Development Environment

First you need to make sure you have the required development packages installed (you can just click the links to install them if you want):

sudo apt-get install gir1.2-unity-3.0 gir1.2-dee-0.5 gir1.2-dbusmenu-glib-0.4

Now, unfortunately not everything you need is packaged just yet. Namely you may need to install the so called Python overrides for the Dee library. Check if you have this file on your system:

/usr/lib/pymodules/python2.7/gi/overrides/Dee.py

If you don’t have that file it means you’re in in the vicinity of the writing of this blog post, in the time dimension; and thus must install it manually. Here’s how. Download Dee.py and copy it to the right location for PyGI to pick it up:

sudo cp Dee.py /usr/lib/pymodules/python2.7/gi/overrides/

With that in place we’re ready to hack.

Writing a Place in Python

The easiest way to start is to check out lp:~unity-team/unity-place-sample/unity-place-python:

bzr branch lp:~unity-team/unity-place-sample/unity-place-python

And then closely follow the README. If you read through it while having the Unity Places spec and IRC log from the devsession at hand you should have a chance of grokking what’s going on. If you have any problems or questions don’t hesitate to ping me on IRC on the #ayatana channel on FreeNode.

I should also add that we’re working on getting some Python API docs for Dee, Dbusmenu, and libunity out. Watch this space!

Tags: , , , ,

9 Responses to “Unity Places – now with 100% More Python”

  1. Neil J Patel Says:

    At least now when we wait three days for search results returning I’ll know who to blame :p

  2. Making your own Unity Place Says:

    [...] which means we can know things that other applications know, and about your data. And as of yesterday you can now write your own Places in Python. This means that people can write Places for just about [...]

  3. Adam Says:

    Broken link.

    https://code.launchpad.net/~unity-team/unity-place-sample/unity-place-python

    Lost something?
    There’s no page with this address in Launchpad.

  4. kamstrup Says:

    @Adam: Sorry about the broken links. Someone decided to be clever and rearrange the entire Unity project structure without me realizing it, blowing up all the links >:-|

  5. andrewsomething Says:

    I found it. It seems that ~unity-team was renamed to ~dx-unity in Launchpad:

    https://code.launchpad.net/~dx-unity/unity-place-sample/unity-place-python

  6. andrewsomething Says:

    Or maybe not:

    $ bzr branch lp:~dx-unity/unity-place-sample/unity-place-python
    bzr: ERROR: Not a branch: “bzr+ssh://bazaar.launchpad.net/~unity-team/unity-place-sample/trunk/”.

  7. kamstrup Says:

    @Andrew – blast. Seems to be a bug in Launchpad or something – because the page https://code.launchpad.net/~dx-unity/unity-place-sample/unity-place-python looks good here, but I get the same error when doing the “bzr branch …”.

    I’ll investigate further on Monday – sorry for the inconvenience :-S

  8. andrewsomething Says:

    Finally got it! It seems to be back at: lp:~unity-team/unity-place-sample/unity-place-python

  9. Tutorial on writing Ubuntu Lenses/Places in Python « God, Your Book Is Great !! Says:

    [...] [2] Unity Places – now with 100% More Python : This blog post contains a brief discussion on developing Unity lenses in Python. It has some info [...]

Leave a Reply