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

Source Code for Module nukescripts.pyQtExamples.pyQtRender

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2  # This example should be used if PySide2 was not built with the Nuke's own binaries 
 3  # otherwise please use pyQtRender2.py 
 4   
 5  import sys, os.path 
 6  import nuke, nukescripts 
 7  from nukescripts import pyQtAppUtils, utils 
 8   
9 -def initPyQtRenderDialog(pyQtApp, appArgv = ['pyQtRenderDialog']):
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 # Set up the user interface from Designer. 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
49 -def startQtRenderDialog():
50 pyQtApp = pyQtAppUtils.pyQtAppHelper(start = True) 51 pyQtApp.run(initPyQtRenderDialog, (pyQtApp,)) 52 return pyQtApp
53