Package nukescripts :: Package pyQtExamples :: Module pyQtRender2
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.pyQtExamples.pyQtRender2

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2  # This example assumes that PySide was built and setup with Nuke's Qt Version 
 3  # !! It will only work in this situation !! 
 4  # otherwise use the other example PyQtRender.py 
 5  import sys, os.path 
 6  import nuke, nukescripts 
 7   
 8  try: 
 9    from PySide import QtCore, QtWidgets, QtUiTools 
10  except: 
11    from PySide2 import QtCore, QtWidgets, QtUiTools 
12   
13 -class pyQtRenderDialog(object):
14 - def __init__(self):
15 # Set up the user interface from Designer. 16 filepath = os.path.join(os.path.dirname(nukescripts.__file__), "pyQtExamples", "pyQtRender.ui") 17 file = QtCore.QFile( filepath ) 18 file.open( QtCore.QIODevice.ReadOnly ) 19 20 loader = QtUiTools.QUiLoader() 21 self.ui = loader.load( file ) 22 self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"), self.render) 23 nuke.addOnCreate(self.onCreateCallback)
24
25 - def showUI(self):
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 i['Render'].execute()
44
45 -def initRenderDialog():
46 dialog = pyQtRenderDialog() 47 dialog.showUI()
48