@@ -721,6 +721,8 @@ def _deserialize_context_menu(self, menu, menu_data):
721721 import sys
722722 import importlib .util
723723
724+ nodes_menu = self .get_context_menu ('nodes' )
725+
724726 def build_menu_command (menu , data ):
725727 """
726728 Create menu command from serialized data.
@@ -745,7 +747,12 @@ def build_menu_command(menu, data):
745747 cmd_func = getattr (mod , data ['function_name' ])
746748 cmd_name = data .get ('label' ) or '<command>'
747749 cmd_shortcut = data .get ('shortcut' )
748- menu .add_command (cmd_name , cmd_func , cmd_shortcut )
750+ cmd_kwargs = {'func' : cmd_func , 'shortcut' : cmd_shortcut }
751+
752+ if menu == nodes_menu and data .get ('node_type' ):
753+ cmd_kwargs ['node_type' ] = data ['node_type' ]
754+
755+ menu .add_command (name = cmd_name , ** cmd_kwargs )
749756
750757 if isinstance (menu_data , dict ):
751758 item_type = menu_data .get ('type' )
@@ -780,7 +787,8 @@ def set_context_menu(self, menu_name, data):
780787 'label': 'test command',
781788 'file': '../path/to/my/test_module.py',
782789 'function': 'run_test',
783- 'shortcut': 'Ctrl+b'
790+ 'shortcut': 'Ctrl+b',
791+ 'node_type': 'nodeGraphQt.nodes.MyNodeClass'
784792 },
785793
786794 ]
@@ -806,6 +814,8 @@ def set_context_menu_from_file(self, file_path, menu=None):
806814 menu (str): name of the parent context menu to populate under.
807815 file_path (str): serialized menu commands json file.
808816 """
817+ file_path = os .path .abspath (file_path )
818+
809819 menu = menu or 'graph'
810820 if not os .path .isfile (file_path ):
811821 return
0 commit comments