State:New|TargetRelease:No Target|icon_bug|icon_nuke|database:public|Resolution:Fixed|BugID:590727|
Problem summary
Setting a shortcut on the createCompSpecial action doesn't work, when running the code from .nuke/Python/Startup.
The same code does work when running it from Nuke Studio's Script Editor instead.
Customer reported version
Nuke Studio 15.1v4
Customer reported platform
Windows 10
Steps to reproduce
1) Save the following code in a Python (.py) file in your .nuke/Python/Startup directory:
from hiero.ui import findMenuAction, registeredActions from PySide2 import QtGui MenuItem = findMenuAction('foundry.timeline.comp.createCompSpecial')MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C')) ERROR:Hiero:Plugin C:/Users/<username>/.nuke\Python\Startup\hotkeys.py could not be loaded: 'NoneType' object has no attribute 'setShortcut'Traceback (most recent call last): File "C:\Program Files\Nuke15.1v4\pythonextensions\site-packages\hiero\core\find_plugins.py", line 42, in loadPluginsFromFolder module = nuke_internal.loadModuleFromPath( moduleName, p ) File "C:\Program Files/Nuke15.1v4/plugins\nuke_internal\utils.py", line 36, in loadModuleFromPath spec.loader.exec_module(mod) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "C:/Users/ThomasRoberts/.nuke\Python\Startup\hotkeys.py", line 5, in <module> MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C'))AttributeError: 'NoneType' object has no attribute 'setShortcut' setShortcut on a kAfterNewProjectCreated event will delay the function from being run until Nuke Studio's GUI has opened:from hiero.ui import findMenuAction, registeredActions from PySide2 import QtGui from hiero.core import eventsdef setCreateCompSpecialHotkey(event): MenuItem = findMenuAction('foundry.timeline.comp.createCompSpecial') MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C'))events.registerInterest(events.EventType.kAfterNewProjectCreated, setCreateCompSpecialHotkey) from hiero.ui import findMenuAction, registeredActions from PySide2 import QtGui MenuItem = findMenuAction('foundry.timeline.effect.createCompSpecial')MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C')) We're sorry to hear that
Please tell us why