1

When my mouse in properties panel, How can I create a shortcut such that when I press 'FIVE' then toggle to modifier panel.enter image description here

Blender Ver: 2.91

X Y
  • 5,234
  • 1
  • 6
  • 20

1 Answers1

4

bpy.ops.wm.context_set_enum(...)

Setting a value from a context path for a shortcut use one of the bpy.ops.wm.context_set... operators

>>> bpy.ops.wm.context_set_
                           boolean(
                           enum(
                           float(
                           id(
                           int(
                           string(
                           value(

This one is an enum property (string would work too)

>>> bpy.ops.wm.context_set_enum(
context_set_enum()
bpy.ops.wm.context_set_enum(data_path="", value="")
Set a context value

For the equivalent to

bpy.context.space_data.context = 'MODIFIERS'

using an operator will be,

bpy.ops.wm.context_set_enum(
        datapath="space_data.context",
        value='MODIFIERS',
        )

cannot test this in python console because it is not in the correct properties space context, instead add it manually to test, Edit > Preferences > Keymaps > Properties Edit

enter image description here

...Ok numpad 5 now switches to modifiers tab.

To set up shortcut using python see

Create keyboard shortcut for an operator using python?*

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • Thank you very much, I click those "small" icons lot of times every day, realy need this solution. – X Y Dec 03 '20 at 00:15