Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KellerPluginManagerGUI.py 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. MENU_ITEM = "&Plugin Manager"
  2. class KellerPluginManagerGUI(KellerNukePlugin):
  3. def configurePlugin(self):
  4. menubar = nuke.menu ('Nuke')
  5. self.m = menubar.addMenu("Edit")
  6. self.m.addCommand(MENU_ITEM, 'KellerPluginManagerGUI.showManager();')
  7. def unconfigurePlugin(self):
  8. self.m.removeItem(MENU_ITEM)
  9. MENU_ITEM = "&Plugin Manager"
  10. MENU_ITEM = "&Plugin Manager"
  11. MENU_ITEM = "&Plugin Manager"
  12. try:
  13. class ShapePanel(nukescripts.PythonPanel):
  14. def __init__(self):
  15. nukescripts.PythonPanel.__init__(self, 'Plugin Manager')
  16. self.setMinimumSize(800, 400)
  17. KPM = KellerPluginManager
  18. plugins = KPM.getPlugins()
  19. for plugin in plugins:
  20. k = nuke.PyScript_Knob("Reload")
  21. k.setLabel("Reload")
  22. k.setName("Button_" + plugin.getName())
  23. k.setFlag(nuke.STARTLINE)
  24. self.addKnob(k)
  25. k = nuke.Boolean_Knob("")
  26. k.setValue(plugin.getState() == KellerNukePlugin.STATE_ACTIVE)
  27. k.setName("Checkbox_" + plugin.getName())
  28. k.setLabel("{0:<30}".format(plugin.getName()))
  29. k.clearFlag(nuke.STARTLINE)
  30. #k.setFlag(nuke.STARTLINE)
  31. self.addKnob(k)
  32. k = nuke.String_Knob("Name","")
  33. k.setValue(plugin.getModule().__file__)
  34. k.clearFlag(nuke.STARTLINE)
  35. self.addKnob(k)
  36. #k = nuke.PyScript_Knob("Reload","Reload","reload(\"%s\")"%plugin.getName())
  37. #self.addSeparator()
  38. k = nuke.PyScript_Knob("Reload All")
  39. k.setLabel("Reload All")
  40. k.setName("Button_ReloadAll")
  41. self.addKnob(k)
  42. k.setFlag(nuke.STARTLINE)
  43. def knobChanged(self, k):
  44. if type(k) == nuke.PyScript_Knob:
  45. if k.name() == "Button_ReloadAll":
  46. reloadAll()
  47. else:
  48. pluginName = k.name().split("_")[1]
  49. plugin = KellerPluginManager.getPluginByName(pluginName)
  50. plugin = KellerPluginManager.reloadPlugin(plugin)
  51. kcheck = self.knobs()["Checkbox_%s" % pluginName]
  52. if kcheck is not None:
  53. if plugin.getState() == KellerNukePlugin.STATE_ACTIVE:
  54. kcheck.setValue(1)
  55. else:
  56. kcheck.setValue(0)
  57. if type(k) == nuke.Boolean_Knob:
  58. pluginName = k.name().split("_")[1]
  59. stateActive = (k.getValue() == 1)
  60. plugin = KellerPluginManager.getPluginByName(pluginName)
  61. if plugin is not None:
  62. if (stateActive) and (plugin.getState() == KellerNukePlugin.STATE_INACTIVE):
  63. plugin.activate()
  64. elif (not stateActive) and (plugin.getState() == KellerNukePlugin.STATE_ACTIVE):
  65. plugin.deactivate()
  66. except:
  67. nuke.debug("Cannot initiate PluginManagerGUI")
  68. def reloadAll():
  69. task = nuke.ProgressTask("Reloading...")
  70. plugins = KellerPluginManager.getPlugins()
  71. i = 0
  72. for plugin in plugins:
  73. i = i + 1
  74. if not task.isCancelled():
  75. task.setMessage("%s" % plugin.getName())
  76. KellerPluginManager.reloadPluginByName(plugin.getName())
  77. task.setProgress(int(i * 100 / len(plugins)))
  78. def showManager():
  79. p = ShapePanel()
  80. p.show()
  81. #showManager()