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

Source Code for Module nukescripts.localisationprefs

 1  """ 
 2  Code for handling changes in the localization default in the preferences 
 3  and applying that as knob defaults on Read nodes. 
 4  """ 
 5   
 6  import nuke 
 7  from PySide2.QtCore import QTimer 
 8   
 9   
10  # Name of the localisation policy prefs knob 
11  kLocalizationPolicyDefaultKnob = "LocalizationPolicyDefault" 
12   
13   
14 -def updateReadKnobLocalisationDefaults(value):
15 """ Set the knob defaults for the nodes with the cacheLocal knob. """ 16 nuke.knobDefault("localizationPolicy", value)
17 18
19 -def onPrefsKnobChanged():
20 """ Callback from the preferences node. If the default localisation 21 policy has changed, update it on the read nodes. 22 """ 23 knob = nuke.thisKnob() 24 if knob.name() == kLocalizationPolicyDefaultKnob: 25 updateReadKnobLocalisationDefaults(knob.value())
26 27
28 -def initCallbacks():
29 """ Get the default localisation policy from the preferences node and set 30 up the knob changed callback. 31 """ 32 prefsNode = nuke.toNode("preferences") 33 knob = prefsNode.knob(kLocalizationPolicyDefaultKnob) 34 updateReadKnobLocalisationDefaults(knob.value()) 35 nuke.addKnobChanged(onPrefsKnobChanged, node=prefsNode)
36 37 38 # This script is imported before the prefs node is loaded. To ensure we get 39 # the correct initial value for the localisation policy, use a QTimer to defer 40 # initialisation. initCallbacks will be called once the Qt event loop is 41 # running. 42 QTimer.singleShot(0, initCallbacks) 43