change keybindings for pygtk treeview

Fabian Braennstroem f.braennstroem at gmx.de
Sat Oct 28 17:29:44 CEST 2006


Hi,

* Fabian Braennstroem <f.braennstroem at gmx.de> wrote:
> Hi,
>
> I am just testing pygtk/glade out and wonder, if I am able
> to change the keybindings. E.g. the treeview searches by
> default for the entries beginning with the typed keystroke;
> moving to the next row works as usual with the Down key. Now
> I would like to change the key bindings to e.g. 'j' to move
> to the next row (just like in vim) and to use a 'Ctrl' key
> combination to search for a certain word beginning with the
> typed key stroke.

I just found out, that I am able to turn it of with
'treeview.set_enable_search(False)'. Works nice.

An option would be, to toggle the searching function with
some keystroke, e.g. 'Ctrl-s'. And set a key binding for the
movement to 'j' and 'k' when the search mode is disabled. I
think I could do it somehow with the 'accelgroup' function,
but did not find enough information to get a clue out of it.

Does anybody have an idea?

In a small curses based file manager (lfm) there is an
assignment of keybindings via a keytable

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',
    ...

Would that work in any way for a pygtk program too?


Greetings!
 Fabian




More information about the Python-list mailing list