domingo, 28 de agosto de 2005

Cool python tricks!

Hey all!

I've been messing around python and pygtk lately. I've managed to code a simple class that implements Tomboy's key grabbing functionality that allows you to simply type '<alt>f11' anywhere on your screen and open a new note.

I am proud to say it's quite simple to use it, simply pass a string as in GTK's accelerator_parse function (like '<ctrl><alt>f11') and a function.


binder = ExternalKeyBinder()

binding = binder.bind("<alt>F8", printer)
gtk.threads_init()
gtk.main()


Since I use a different thread to listen for the Xlib key press event, I have to call that strange gtk.threads_init() function.

This code depends on python-xlib and pygtk (for doing the string parsing thingy). Oh! And that class is a GObject.

It is not a finished work (that are some details about keymap modifiers that I have to review and no documentations yet :) ), but you can get it here.

sábado, 20 de agosto de 2005

Time

There is something truely fascinating about this little flash animation. I think it shows a primordial flaw in the design of clocks: they shouldn't be made circular. By making it so, we lose a precious notion of the speed that time sleeps away from us. Also, since it's interface is periodic, we are tempted to think we may regain the time lost the next time the little pointers cross this point again tomorrow, of the day after that.