On 10/03/2010 09:16, Steven D'Aprano wrote:
Perhaps all you need is a single dict, mapping characters to functions:funcs = { # Just a dict # keycode: function 'q': exitProgram, 'a': arm.sayLoad1 # etc. } Then whenever you get a keyboard event, convert it to the character: keycode = 113 c = chr(keycode) funcs(c)()
FWIW (altho' it's not clear from the OP's code) he's basically doing this: http://timgolden.me.uk/python/win32_how_do_i/catch_system_wide_hotkeys.html which uses the dictionary keys as an id in the call to RegisterHotKey. Obviously, that doesn't explain why he's building lists of dictionaries. TJG -- http://mail.python.org/mailman/listinfo/python-list
