(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. 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:
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.
Powered by Bilbo Blogger