[pygtk] Re: adjust key bindings
Fabian Braennstroem
f.braennstroem at gmx.de
Sun Nov 19 03:14:25 WST 2006
Hi,
sorry, is that question to stupid or does nobody has a hint?
* On 14 Nov 2006 * Fabian Braennstroem wrote:
> Hi,
>
> I just start to use pygtk ... so it is just my first
> question :-)
>
> I would like to create a small file manager based on 'lfm'
> (curses based file manager). I used glade for the gui and I
> am able to display the existing files and directories using
> two treeview widgets.
> Now, at the beginning I am kind of stuck with the key bindings. In 'lfm'
> it was pretty easy to define special key bindings:
>
>
> keytable = {
> # movement
> ord('p'): 'cursor_up',
> ord('k'): 'cursor_up',
> ord('K'): 'cursor_up2',
> ord('P'): 'cursor_up',
> curses.KEY_UP: 'cursor_up',
> ord('n'): 'cursor_down',
> ord('j'): 'cursor_down',
> ord('J'): 'cursor_down2',
> ord('N'): 'cursor_down',
> curses.KEY_DOWN: 'cursor_down',
> curses.KEY_PPAGE: 'page_previous',
> curses.KEY_BACKSPACE: 'page_previous',
> 0x08: 'page_previous', # BackSpace
> 0x10: 'page_previous', # Ctrl-P
> curses.KEY_NPAGE: 'page_next',
> ord(' '): 'page_next',
> 0x0E: 'page_next', # Ctrl-N
> curses.KEY_HOME: 'home',
> 0x16A: 'home',
> ord('H'): 'home',
> 0x001: 'home',
> curses.KEY_END: 'end',
> ord('G'): 'end',
> 0x181: 'end',
> 0x005: 'end',
> ord('h'): 'cursor_left',
> ord('l'): 'cursor_right',
> curses.KEY_LEFT: 'cursor_left',
> curses.KEY_RIGHT: 'cursor_right',
> ord('g'): 'goto_dir',
> 0x13: 'goto_file', # Ctrl-S
> 0x14: 'tree', # Ctrl-T
> ord('0'): 'bookmark_0',
> ord('1'): 'bookmark_1',
> ...
>
>
> with such a keytable I am able to bind different 'def's to
> every existing key. As you can see, I like it a lot to use
> 'vim-like' keys for moving around; 'j' and 'k' to move a row
> up and down. In glade I found those 'accelerators', but it
> is just for certain functions.
> Does anyone have an idea about using such a keybinding in
> pygtk? Would be nice!
>
Greetings!
Fabian
More information about the pygtk
mailing list