shortcuteditor-nuke
shortcuteditor-nuke copied to clipboard
Separate custom menus cannot be detected
Separate custom menus cannot be detected
menubar=nuke.toolbar("custom_tool") m=menubar.addMenu("custom_tool", "nuke1.png") tf = m.addMenu('Tran sform', icon='Transform.png') tf.addCommand( "ConvertCornerP in", "convertCornerP in()", icon = "CornerPin.png" )
Ah, interesting, I haven't really ever used custom toolbars so never really thought about them, but that makes sense
The code currently only looks in a fixed set of top level menus (e.g nuke.menu("Node Graph")
etc),
https://github.com/dbr/shortcuteditor-nuke/blob/a74592e052d8364d078f8a3237787977180e4164/shortcuteditor.py#L530
It would be fairly easy to add in custom toolbars too.. but only if there is a API method to list them. It's possible to do nuke.toolbar("custom_tool", create=False)
to get access to the nuke.Menu
item, but I can't find an API method to list all toolbars (and since they can be named anything, it doesn't make sense to fix the list like with the built-in menus)
Contacted Foundry support and they have a workaround for the missing API - can find the toolbars with the following code - I shall try and integrate this sometime soon!
from Qt import QtCore, QtGui, QtWidgets
def findPanelIDs():
found_toolbars = []
stack = QtWidgets.QApplication.topLevelWidgets()
for x in range(1000):
if not stack:
# Done when stack is empty
break
widget = stack.pop()
if widget.windowTitle():
if widget.objectName().startswith("Toolbar_"):
tb = nuke.toolbar(widget.windowTitle(), create=False)
if tb is not None:
found_toolbars.append(tb)
stack.extend(c for c in widget.children() if c.isWidgetType())
return found_toolbars
findPanelIDs()
Looking forward to update