def buildPresetDeletePanel(): presets = [] presets = nuke.getPresets() if presets == []: nuke.message("No presets defined.") else: PresetsDeletePanel().showModalDialog()
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Delete Preset', 'uk.co.thefoundry.DeletePreset') self.presets = [] self.presets = nuke.getPresets() self.menuItemChoice = nuke.Enumeration_Knob('menuItemChoice', 'Menu item', self.presets) self.okButton = nuke.PyScript_Knob('delete', 'Delete') self.okButton.setFlag(0x00001000) self.cancelButton = nuke.PyScript_Knob('cancel', 'Cancel') # ADD KNOBS self.addKnob(self.menuItemChoice) self.addKnob(self.okButton) self.addKnob(self.cancelButton)
def populatePresetsMenu(nodeName, className): knobValues = {} node = nuke.toNode(nodeName) m = nuke.getPresetsMenu(node) # reset the menus in case of preset deletion m.clearMenu() presets = [] userpresets = [] userpresets = nuke.getUserPresets(node) presets = nuke.getPresets(node) allpresets = userpresets + presets buildSavePanelFunc = lambda node=node: nukescripts.buildPresetSavePanel( "", node) m.addCommand("Save as Preset", buildSavePanelFunc) if allpresets != []: m.addCommand("-", "", "") for k in userpresets: f = lambda node=node, k=k: nuke.applyUserPreset("", k, node) m.addCommand('[User] ' + k, f) for k in presets: f = lambda node=node, k=k: nuke.applyPreset("", k, node) m.addCommand(k, f) if allpresets != []: m.addCommand("-", "", "") n = m.addMenu("Delete Preset") for k in userpresets: n.addCommand( '[User] ' + k, 'nukescripts.deleteUserNodePreset("%s", "%s")\n' % (className, k)) for k in presets: n.addCommand( k, 'nukescripts.deleteNodePreset("%s", "%s")\n' % (className, k))