#NEWLINE# def _run( self , args ) : #NEWLINE# #INDENT# self . _executeStartupFiles ( 'gui' ) #NEWLINE# GafferUI . ScriptWindow . connect ( self . root ( ) ) #NEWLINE# script = Gaffer . ScriptNode ( ) #NEWLINE# script [ 'fileName' ] . setValue ( os . path . abspath ( args [ 'script' ] . value ) ) #NEWLINE# script . load ( ) #NEWLINE# self . root ( ) [ 'scripts' ] . addChild ( script ) #NEWLINE# scriptWindow = GafferUI . ScriptWindow . acquire ( script ) #NEWLINE# self . setGrabWidget ( scriptWindow ) #NEWLINE# if args [ 'editor' ] . value : #NEWLINE# #INDENT# editor = args [ 'editor' ] . value #NEWLINE# if ( '.' not in editor ) : #NEWLINE# #INDENT# editor = ( 'GafferUI.' + editor ) #NEWLINE# #UNINDENT# editorPartition = editor . rpartition ( '.' ) #NEWLINE# editor = getattr ( __import__ ( editorPartition [ 0 ] ) , editorPartition [ 2 ] ) #NEWLINE# editors = scriptWindow . getLayout ( ) . editors ( editor ) #NEWLINE# if ( not editors ) : #NEWLINE# #INDENT# IECore . msg ( IECore . Msg . Level . Error , 'screengrab' , ( 'Unable to find an editor of type "%s"' % editor ) ) #NEWLINE# return 1 #NEWLINE# #UNINDENT# self . setGrabWidget ( editors [ 0 ] ) #NEWLINE# #UNINDENT# self . __waitForIdle ( ) #NEWLINE# for nodeGraph in scriptWindow . getLayout ( ) . editors ( GafferUI . NodeGraph ) : #NEWLINE# #INDENT# nodeGraph . frame ( script . children ( Gaffer . Node ) ) #NEWLINE# #UNINDENT# self . __waitForIdle ( ) #NEWLINE# d = { #NEWLINE# #INDENT# 'application' : self , #NEWLINE# 'script' : nodeGraph , #NEWLINE# #UNINDENT# } #NEWLINE# if args [ 'cmd' ] . value : #NEWLINE# #INDENT# exec ( args [ 'cmd' ] . value , d , d ) #NEWLINE# #UNINDENT# if args [ 'cmdfile' ] . value : #NEWLINE# #INDENT# execfile ( args [ 'cmdfile' ] . value , d , d ) #NEWLINE# #UNINDENT# self . __waitForIdle ( ) #NEWLINE# imageDir = os . path . dirname ( args [ 'image' ] . value ) #NEWLINE# if ( imageDir and ( not os . path . isdir ( imageDir ) ) ) : #NEWLINE# #INDENT# IECore . msg ( IECore . Msg . Level . Info , 'screengrab' , ( 'Creating target directory [ %s ]' % imageDir ) ) #NEWLINE# os . makedirs ( imageDir ) #NEWLINE# #UNINDENT# pixmap = QtGui . QPixmap . grabWindow ( self . getGrabWidget ( ) . _qtWidget ( ) . winId ( ) ) #NEWLINE# IECore . msg ( IECore . Msg . Level . Info , 'screengrab' , ( 'Writing image [ %s ]' % args [ 'image' ] . value ) ) #NEWLINE# pixmap . save ( args [ 'image' ] . value ) #NEWLINE# return 0