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 PyQt4 was not built with the Nuke's own binaries 
 3  # otherwise please use pyQtRender2.py 
 4  import sys, os.path 
 5  from nukescripts import pyQtAppUtils, utils 
 6  import nuke 
 7   
8 -def initPyQtRenderDialog(pyQtApp, appArgv = ['pyQtRenderDialog']):
9 from PyQt4 import QtCore, QtGui, uic 10 11 class pyQtRenderDialog(object): 12 def __init__(self): 13 # Set up the user interface from Designer. 14 self.ui = uic.loadUi(os.path.join(os.path.dirname(nukescripts.__file__), "pyQtExamples", "pyQtRender.ui")) 15 self.ui.connect(self.ui.renderButton, QtCore.SIGNAL("clicked()"), self.render) 16 nuke.addOnCreate(self.onCreateCallback) 17 self.ui.show()
18 19 def onCreateCallback(self): 20 n = nuke.thisNode() 21 if n.Class() == "Write": 22 n.setName(n.name()) 23 self.addItem(n) 24 25 def addItem(self, n): 26 item = QtGui.QTreeWidgetItem() 27 item.setText(0, n['name'].value()) 28 self.ui.treeWidget.addTopLevelItem(item) 29 30 def render(self): 31 selectedItems = self.ui.treeWidget.selectedItems() 32 writeNodes = [j for i in selectedItems for j in nuke.allNodes() if j.Class() == "Write" and j['name'].value() == i.text(0)] 33 for i in writeNodes: 34 utils.executeInMainThread(i['Render'].execute) 35 36 app = pyQtApp.getApplication(appArgv) 37 dialog = pyQtRenderDialog() 38 app.exec_() 39
40 -def startQtRenderDialog():
41 pyQtApp = pyQtAppUtils.pyQtAppHelper(start = True) 42 pyQtApp.run(initPyQtRenderDialog, (pyQtApp,)) 43 return pyQtApp
44