Notes for PythonForArtists - SimpleUserInterfaces (legacy) - video tutorial

PythonForArtists_SimpleUserIntervaces (legacy) - Frank Rueter

click here for video

Nuke has pretty simple python commands that let you create simple user interfaces - without having to dive too much into python panels.

Print a pop up mesage:

nuke.message ( 'yay' )
txt = str( len( nuke.allNodes() ) )
nuke.message( txt + ' nodes in the script')

Screen_shot_2010-07-05_at_12.17.58_PM
Nuke.display method:

Nuke.display uses four arguments (s,o,t,w), explanation from running help (nuke.display) :

Creates a dialog box showing the result of a script. The s argument is a python script, o is a Nuke node that provides the "context" of execution, t is an optional argument to set the window title and w is an optional argument for a preferred window width.
Creates a window showing the result of command. The command is executed in the "context" of the given node, so this and a knob name in expressions refer to that node. In the window is an "update" button which causes the command to be run again.

Simple script to return the channel status of a selected node:

def showChannels():
    return '\n'.join( nuke.thisNode().channels() )
 
nuke.display( 'showChannels()', nuke.selectedNode(), 'show channels')

Screen_shot_2010-07-05_at_1.17.55_PM
Nuke.getInput method:

Change labels:

txt = nuke.getInput( 'Change Label', 'new label' )
if not txt == None:
    for n in nuke.selectedNodes():
        n.knob('label').setValue( txt )

Change labels with colour coding (tile and gl colours):

col = nuke.getColor()
if not col == None:
    for n in nuke.selectedNodes():
        n.knob('tile_color').setValue( col )
        n.knob('gl_color').setValue( col )


 

Screen_shot_2010-07-05_at_1.29.43_PM

Browsing for files:

Start with help(nuke.getFilename) for an explanation on the function getFilename.
 

defDir = '/Users/frank/dailies/'
filePath = nuke.getFilename( 'Get Dailies Notes', '*.txt *.xml', defDir)
 
if not filePath == None:
    file = open(filePath, 'r')
    content = file.read()
    file.close()
 
htmlStr = ''
 
nuke.nodes.StickyNote( label = htmlStr + '\n' + content, note_font_size = 20)

Screen_shot_2010-07-05_at_1.42.26_PM

Browsing for image sequences:

nuke.getClipname('test')

Selecting ranges to process:

nuke.getFramesAndViews('get range', '1-10')

Selecting ranges to process with mutually exclusive choice for left and right:

nuke.getFramesAndViews('get range', '1-10', 1)