Blog‎ > ‎

Simple Hotkey Setup

posted Oct 17, 2018, 9:51 PM by Levente Vass   [ updated Oct 25, 2018, 7:10 AM ]
  # Python       

Small code snippet for hotkey setup, extend hotkeys nested list with new items,  usage:
['Draw/Grain',           'Grain2',                  'Alt+I']
⇑ ⇑
Path/to/node Node class, Hotkey
   
          and default values (optional)

# insert code snippet to menu.py
menu = nuke.menu('Nodes') hotkeys = [ ['Filter/Blur', 'Blur, size 20 label "hello world"', 'B'], ['Draw/LightWrap', 'LightWrap', 'L'], ['Draw/Grain', 'Grain2', 'Alt+I']
# ... your hotkeys
]
def assign_hotkey(n_path, c_node, h_key):
"""Batch hotkey assignment.

Parameters
----------
n_path: str
the node path in the menu
c_node: str
node class
h_key: str
assigned hotkey

Returns
-------
None

"""
c_node_splitted = c_node.split(',') menu.addCommand(n_path, lambda: nuke.createNode(*c_node_splitted), h_key)
n_path_i = 0 c_node_i = 1 h_key_i = 2 for i in hotkeys: assign_hotkey(i[n_path_i], i[c_node_i], i[h_key_i])

ċ
hotkey_assign.py
(1k)
Levente Vass,
Oct 25, 2018, 7:10 AM
Comments