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

Source Code for Module nukescripts.scripteditorknob

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