I notice this in both operators:
### Mine (that does not work)
bpy.context.window_manager.keyconfigs['Blender addon'].keymaps['Object Mode'].keymap_items.new('screen.userpref_show','TAB', 'PRESS', ctrl=True)
### Vaughan Ling (HEAVYPOLY) (that does work)
bpy.context.window_manager.keyconfigs.addon.keymaps.new(name='Object Mode').keymap_items.new("screen.userpref_show","TAB","PRESS", ctrl=True)
and what surprises me is that this one that I figured before however works:
bpy.context.window_manager.keyconfigs['Blender'].keymaps['Mesh'].keymap_items.new('mesh.select_more', 'Z', 'PRESS',alt=True)
Would anyone happen to know why the 3rd one works and the 1st one does not? even though
import bpy
# Get the key configuration for Blender
keyconfig = bpy.context.window_manager.keyconfigs['Blender']
# Iterate over keymaps and print their names
for keymap in keyconfig.keymaps:
print(keymap.name)
gives me Object Mode
in the printed for loop
and to double check:
import bpy
# Get the key configuration for Blender
keyconfig = bpy.context.window_manager.keyconfigs['Blender']
# Iterate over keymaps and print their names
if 'Object Mode' in keyconfig.keymaps:
print(keyconfig.keymaps['Object Mode'])
### <bpy_struct, KeyMap("Object Mode") at 0x779125fc7988>