1
2
3
4
5 import sys, os.path
6 import nuke, nukescripts
7 from nukescripts import pyQtAppUtils, utils
8
10 try:
11 from PySide import QtCore, QtWidgets, QtUiTools
12 except:
13 from PySide2 import QtCore, QtWidgets, QtUiTools
14
15 class pyRenderDialog(object):
16 def __init__(self):
17
18 filepath = os.path.join(os.path.dirname(nukescripts.__file__), "pyQtExamples", "pyQtRender.ui")
19 file = QtCore.QFile( filepath )
20 file.open( QtCore.QIODevice.ReadOnly )
21
22 loader = QtUiTools.QUiLoader()
23 self.ui = loader.load( file )
24 self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"), self.render)
25 nuke.addOnCreate(self.onCreateCallback)
26 self.ui.show()
27
28 def onCreateCallback(self):
29 n = nuke.thisNode()
30 if n.Class() == "Write":
31 n.setName(n.name())
32 self.addItem(n)
33
34 def addItem(self, n):
35 item = QtWidgets.QTreeWidgetItem()
36 item.setText(0, n['name'].value())
37 self.ui.treeWidget.addTopLevelItem(item)
38
39 def render(self):
40 selectedItems = self.ui.treeWidget.selectedItems()
41 writeNodes = [j for i in selectedItems for j in nuke.allNodes() if j.Class() == "Write" and j['name'].value() == i.text(0)]
42 for i in writeNodes:
43 utils.executeInMainThread(i['Render'].execute)
44
45 app = pyQtApp.getApplication(appArgv)
46 dialog = pyQtRenderDialog()
47 app.exec_()
48
53