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.
Nenhum comentário:
Postar um comentário