Package nukescripts :: Module scripteditorknob
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.scripteditorknob

 1  import nuke 
 2  from PySide.QtGui import * 
 3  from blinkscripteditor import * 
 4   
5 -class ScriptEditor(QWidget):
6 7 doNotUpdate = False 8
9 - def __init__(self, knob, parent=None):
10 super(ScriptEditor, self).__init__(parent) 11 12 self.knob = knob 13 #doNotUpdate is used to prevent circular updates when a user enters text. 14 self.doNotUpdate = False 15 16 #Set title 17 self.setWindowTitle("BlinkScript Editor") 18 19 #Make splitter 20 splitter = PySide.QtGui.QSplitter(PySide.QtCore.Qt.Vertical) 21 22 #Setup main layout 23 self.myTextWindow = ScriptInputArea(None, self, self) 24 splitter.addWidget(self.myTextWindow) 25 26 layout = PySide.QtGui.QVBoxLayout() 27 self.setLayout(layout) 28 layout.addWidget(splitter) 29 30 #Update the stored text on the knob when the user changes it 31 self.myTextWindow.userChangedEvent.connect(self.storeTextOnKnob)
32
33 - def printText(self):
34 data = self.myTextWindow.toPlainText() 35 print str(data)
36
37 - def getText(self):
38 data = self.myTextWindow.toPlainText() 39 return data
40
41 - def storeTextOnKnob(self):
42 self.doNotUpdate = True 43 self.knob.setText(self.myTextWindow.toPlainText())
44
45 - def updateValue(self):
46 #Update the UI text from the knob 47 if not self.doNotUpdate: 48 self.myTextWindow.setPlainText(self.knob.getText()) 49 self.doNotUpdate = False 50 # knob value changed 51 pass
52
53 -class ScriptEditorWidgetKnob():
54 - def __init__(self, knob):
55 self.knob = knob
56
57 - def makeUI(self):
58 return ScriptEditor(self.knob)
59 60
61 -def makeScriptEditorKnob():
62 return ScriptEditorWidgetKnob(nuke.thisKnob())
63