(Seemingly, the only) working Pyclutter examples.

So, I’ve been hacking for about 24 hours straight on getting a nice bit of code written for Fedora-tour using the Clutter UI toolkit, the toolkit used to program the new gnome-shell and some other fancy stuff. Unfortunately, I chose to use the python bindings for clutter, called, sensibly enough, pyclytter. ZOMG, we’ll see if that was a mistake soon.

The first issue, which is strange to me still, and resulted in three posts at fedora-devel, with me answering my own issue, was that my python code was randomly segfaulting (I laugh when I see that) because it makes calls into a compiled, I assume, bridge library between the clutter libraries and the python bindings. OHFUN. So, after trying to get some useful debugging from it for about 18 of those 24 hours (six of the 18 were sleep, admittedly) I rebooted my system for upgrade purposes and lo and behold! my code works! Idk, either. LD fun? who knows, who cares? I’ve raged enough over it for two lifetimes 🙂

The second issue was the complete and total lack of pyclutter documentation and example code. PyClutter was packaged in Fedora, I’d assume for one application, the media-center application entertainer, which is broken with the version of PyClutter we ship.[1] Oh dear.

On top of that, there are virtually no working examples of PyClutter on the internet, as far as I can tell. Google Code search lists two, which I’ve stuck here for good posterity:

ClutterMediator.py from coverartclutter

launcher-gtk.py from libchamplain

And the official docs.

There is also one hello world example that didn’t work for the version of pyclutter that Fedora 12 ships.

So, I fixed it. This provides a quick crash course of a few different things to do in clutter. You can also, I learned, create a clutter stage embedded in a gtk.Window, which is freaking cool. The code is fairly simple to do it, and it’s what Fedora-tour is doing:

#add the embedded clutter canvas to the gtk window
self.embed = cluttergtk.Embed()

#realize the object and get the Clutter stage.
windowSize = self.mainWindow.get_size()
stage = self.embed.get_stage()

At which point you have a clutter stage you can do whatever with. Enjoy. 🙂 Clutter is a really nice toolkit, and the python bindings make code quick and easy. Fedora-tour is going to have some cool dynamic introduction scenes. 🙂 It’s just too bad there isn’t more easy to use code out there in the wild.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=526035

Powered by Bilbo Blogger


~ by Ryan Rix on 21 December 2009.

7 Responses to “(Seemingly, the only) working Pyclutter examples.”

  1. […] from: Ryan Rix "PhrkOnLsh": (Seemingly, the only) working Pyclutter examples. Share and […]

  2. The new “hello world” link, https://fedorahosted.org/fedora-tour/browser/frontend/test.py, gives an error message, “No node /frontend/test.py at revision 3ab6b6564fa223f53202f75906afdb4d5ffaf44f”.

    I dug around for 30 more seconds and found it at https://fedorahosted.org/fedora-tour/browser/docs/learning_refs/test.py – might want to back-edit and change the link?

  3. You rock, Mel 🙂 I updated the post

  4. For a while, I did debate updating the hello_world example to pyclutter 1.0 because the code was written for pyclutter 0.6.

    Perhaps an update and a new post are in order?

    The clutter project has a directory of examples bundled with the pyclutter source available at http://www.clutter-project.org/sources/pyclutter/1.0/

  5. Hey Jezra;

    That test.py is your script made to work with 0.9.2 🙂 feel free to use it, it’s under public domain afaik (whatever license you had it under?) 🙂

  6. The test.py also works with clutter 1.0.8. Thanks for keeping the old code alive. Are you interested in a small tweak? (I hope you said “yes”)
    The comment on line 48 mentions the “ramp_inc_func” which no longer exists and has been replaced with “clutter.LINEAR”, while the mode used in line 49 is “clutter.EASE_IN_CIRC”

  7. Hey Jezra,
    I just picked the only one that really made sense 🙂 I didn’t know clutter.LINEAR existed… I got that from `pydoc clutter` after seeing a similar one (clutter.EASE_IN_SINE) in some random google code search 🙂

    When I push the code will be updated. Thanks for help, Jezra! I think that when I have a full grasp on the pyclutter API I will write a nice test application for the entire API. I’ll also be taking a look at the examples you pointed out to me above 😉


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: