本文整理汇总了Python中Gaffer类的典型用法代码示例。如果您正苦于以下问题:Python Gaffer类的具体用法?Python Gaffer怎么用?Python Gaffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gaffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _popupMenu
def _popupMenu( menuDefinition, plugValueWidget ) :
compoundNumericPlugValueWidget = None
if isinstance( plugValueWidget, GafferUI.CompoundNumericPlugValueWidget ) :
compoundNumericPlugValueWidget = plugValueWidget
else :
plugWidget = plugValueWidget.ancestor( GafferUI.PlugWidget )
if plugWidget is not None and isinstance( plugWidget.plugValueWidget(), GafferUI.CompoundNumericPlugValueWidget ) :
compoundNumericPlugValueWidget = plugWidget.plugValueWidget()
if compoundNumericPlugValueWidget is None :
return
if compoundNumericPlugValueWidget.getPlug().isGanged() :
menuDefinition.append( "/GangDivider", { "divider" : True } )
menuDefinition.append( "/Ungang", {
"command" : Gaffer.WeakMethod( compoundNumericPlugValueWidget.__ungang ),
"shortCut" : "Ctrl+G",
"active" : not plugValueWidget.getReadOnly() and not Gaffer.readOnly( compoundNumericPlugValueWidget.getPlug() ),
} )
elif compoundNumericPlugValueWidget.getPlug().canGang() :
menuDefinition.append( "/GangDivider", { "divider" : True } )
menuDefinition.append( "/Gang", {
"command" : Gaffer.WeakMethod( compoundNumericPlugValueWidget.__gang ),
"shortCut" : "Ctrl+G",
"active" : not plugValueWidget.getReadOnly() and not Gaffer.readOnly( compoundNumericPlugValueWidget.getPlug() ),
} )
示例2: testCopyPaste
def testCopyPaste( self ) :
s = Gaffer.ScriptNode()
s["b"] = Gaffer.Box()
s["b"]["a1"] = GafferTest.AddNode()
s["b"]["a2"] = GafferTest.AddNode()
s["b"]["a2"]["op1"].setInput( s["b"]["a1"]["sum"] )
s["b"].promotePlug( s["b"]["a1"]["op1"] )
s["b"].exportForReference( self.temporaryDirectory() + "/test.grf" )
s["r"] = Gaffer.Reference()
s["r"].load( self.temporaryDirectory() + "/test.grf" )
self.assertTrue( Gaffer.readOnly( s["r"]["a1"] ) )
self.assertTrue( Gaffer.readOnly( s["r"]["a2"] ) )
s.execute( s.serialise( parent = s["r"], filter = Gaffer.StandardSet( [ s["r"]["a1"], s["r"]["a2"] ] ) ) )
self.assertTrue( "a1" in s )
self.assertTrue( "a2" in s )
self.assertTrue( s["a2"]["op1"].getInput().isSame( s["a1"]["sum"] ) )
self.assertFalse( Gaffer.readOnly( s["a1"] ) )
self.assertFalse( Gaffer.readOnly( s["a2"] ) )
示例3: __init__
def __init__( self, node, **kw ) :
column = GafferUI.ListContainer( spacing = 4 )
GafferUI.Widget.__init__( self, column, **kw )
self.__node = node
with column :
with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :
GafferUI.Label( "Language" )
self.__languageMenu = GafferUI.MenuButton( "", menu = GafferUI.Menu( Gaffer.WeakMethod( self.__languageMenuDefinition ) ) )
self.__languageMenu.setEnabled( not Gaffer.readOnly( node ) )
self.__textWidget = GafferUI.MultiLineTextWidget( role = GafferUI.MultiLineTextWidget.Role.Code )
self.__textWidget.setEditable( not Gaffer.readOnly( node ) )
self.__activatedConnection = self.__textWidget.activatedSignal().connect( Gaffer.WeakMethod( self.__activated ) )
self.__editingFinishedConnection = self.__textWidget.editingFinishedSignal().connect( Gaffer.WeakMethod( self.__editingFinished ) )
self.__dropTextConnection = self.__textWidget.dropTextSignal().connect( Gaffer.WeakMethod( self.__dropText ) )
self.__messageWidget = GafferUI.MessageWidget()
self.__expressionChangedConnection = self.__node.expressionChangedSignal().connect( Gaffer.WeakMethod( self.__expressionChanged ) )
self.__errorConnection = self.__node.errorSignal().connect( Gaffer.WeakMethod( self.__error ) )
self.__update()
示例4: __plugMetadataChanged
def __plugMetadataChanged( self, nodeTypeId, plugPath, key, plug ) :
if self.__plug is None :
return
if (
Gaffer.affectedByChange( self.__plug, nodeTypeId, plugPath, plug ) or
( key == "readOnly" and Gaffer.ancestorAffectedByChange( self.__plug, nodeTypeId, plugPath, plug ) )
) :
self._updateFromPlug()
示例5: __applyReadOnly
def __applyReadOnly( self, readOnly ) :
def clearFlags( plug ) :
plug.setFlags( Gaffer.Plug.Flags.ReadOnly, False )
for child in plug.children() :
clearFlags( child )
with Gaffer.UndoContext( self.getPlug().ancestor( Gaffer.ScriptNode.staticTypeId() ) ) :
# We used to use a plug flag, but we use metadata now
# instead. Clear the old flags so that metadata is in
# control.
clearFlags( self.getPlug() )
Gaffer.setReadOnly( self.getPlug(), readOnly )
示例6: _qtImport
def _qtImport( name, lazy=False ) :
# decide which qt bindings to use, and apply any fix-ups we need
# to shield us from PyQt/PySide differences.
global __qtModuleName
if __qtModuleName is None :
import os
if "GAFFERUI_QT_BINDINGS" in os.environ :
__qtModuleName = os.environ["GAFFERUI_QT_BINDINGS"]
else :
# no preference stated via environment - see what we shipped with
if os.path.exists( os.environ["GAFFER_ROOT"] + "/python/PySide" ) :
__qtModuleName = "PySide"
else :
__qtModuleName = "PyQt4"
# PyQt unfortunately uses an implementation-specific
# naming scheme for its new-style signal and slot classes.
# We use this to make it compatible with PySide, according to :
#
# http://qt-project.org/wiki/Differences_Between_PySide_and_PyQt
if "PyQt" in __qtModuleName :
QtCore = __import__( __qtModuleName + ".QtCore" ).QtCore
QtCore.Signal = QtCore.pyqtSignal
# import the submodule from those bindings and return it
if lazy :
import Gaffer
return Gaffer.lazyImport( __qtModuleName + "." + name )
else :
qtModule = __import__( __qtModuleName + "." + name )
return getattr( qtModule, name )
示例7: __menuDefinition
def __menuDefinition( self ) :
result = IECore.MenuDefinition()
url = Gaffer.Metadata.value( self.nodeUI().node(), "documentation:url" )
result.append(
"/Documentation...",
{
"active" : bool( url ),
"command" : functools.partial( GafferUI.showURL, url ),
}
)
result.append( "/DocumentationDivider", { "divider" : True } )
result.append(
"/Revert to Defaults",
{
"command" : Gaffer.WeakMethod( self.__revertToDefaults ),
"active" : not Gaffer.readOnly( self.nodeUI().node() ),
}
)
self.toolMenuSignal()( self, self.nodeUI().node(), result )
return result
示例8: __nodeGraphPlugContextMenu
def __nodeGraphPlugContextMenu( nodeGraph, plug, menuDefinition ) :
if not isinstance( plug.node(), GafferScene.Shader ) :
return
if not (
plug.node()["parameters"].isAncestorOf( plug ) or
plug.node()["out"].isAncestorOf( plug )
) :
return
if len( menuDefinition.items() ) :
menuDefinition.append( "/HideDivider", { "divider" : True } )
if plug.direction() == plug.Direction.In :
numConnections = 1 if plug.getInput() else 0
else :
numConnections = len( plug.outputs() )
menuDefinition.append(
"/Hide",
{
"command" : functools.partial( __setPlugMetadata, plug, "noduleLayout:visible", False ),
"active" : numConnections == 0 and not Gaffer.readOnly( plug ),
}
)
示例9: __clicked
def __clicked( self, button ) :
if Gaffer.readOnly( self.__node["context"] ) :
return
with Gaffer.UndoScope( self.__node.ancestor( Gaffer.ScriptNode ) ) :
self.__node["context"].addOptionalMember( "", "", enabled = True )
示例10: __plugMetadataChanged
def __plugMetadataChanged( self, nodeTypeId, plugPath, key, plug ) :
if self.getPlug() is None :
return
if key=="label" and Gaffer.affectedByChange( self.getPlug(), nodeTypeId, plugPath, plug ) :
self.__updateFormatter()
示例11: applyDefaults
def applyDefaults( graphComponent ) :
if isinstance( graphComponent, Gaffer.Plug ) :
plug = graphComponent
if plug.direction() == plug.Direction.Out :
return
elif plug.isSame( plug.node()["user"] ) :
# Not much sense reverting user plugs, since we
# don't expect the user to have gone to the trouble
# of giving them defaults.
return
elif plug.getName().startswith( "__" ) :
# Private plugs are none of our business.
return
elif Gaffer.readOnly( plug ) :
return
if isinstance( plug, Gaffer.ValuePlug ) :
if plug.settable() :
plug.setToDefault()
return
for c in graphComponent.children( Gaffer.Plug ) :
applyDefaults( c )
示例12: __namesPopupMenu
def __namesPopupMenu( menuDefinition, plugValueWidget ) :
plug = plugValueWidget.getPlug()
node = plug.node()
if not isinstance( node, GafferScene.DeleteGlobals ) :
return
if plug != node["names"] :
return
with plugValueWidget.getContext() :
globals = node["in"]["globals"].getValue()
currentNames = set( node["names"].getValue().split() )
prefix = node._namePrefix()
names = [ n for n in globals.keys() if n.startswith( prefix ) ]
if not names :
return
menuDefinition.prepend( "/NamesDivider", { "divider" : True } )
menuPrefix = "/" + node.typeName().rsplit( ":" )[-1].replace( "Delete", "" ) + "/"
for name in reversed( sorted( list( names ) ) ) :
nameWithoutPrefix = name[len(prefix):]
menuDefinition.prepend(
menuPrefix + nameWithoutPrefix,
{
"command" : IECore.curry( __toggleName, plug, nameWithoutPrefix ),
"active" : plug.settable() and not plugValueWidget.getReadOnly() and not Gaffer.readOnly( plug ),
"checkBox" : nameWithoutPrefix in currentNames,
}
)
示例13: _updateFromPlug
def _updateFromPlug( self ) :
with self.getContext() :
shaderName = self.getPlug().getValue()
self.__label.setText( "<h3>Shader : " + shaderName + "</h3>" )
## \todo Disable the type check once we've got OpenGLShader implementing reloading properly.
self.__button.setEnabled( not Gaffer.readOnly( self.getPlug() ) and not isinstance( self.getPlug().node(), GafferScene.OpenGLShader ) )
示例14: __popupMenu
def __popupMenu( menuDefinition, plugValueWidget ) :
plug = plugValueWidget.getPlug()
if not isinstance( plug, Gaffer.ValuePlug ) :
return
node = plug.node()
if node is None or node.parent() is None :
return
input = plug.getInput()
if input is not None or not plugValueWidget._editable() or Gaffer.readOnly( plug ) :
return
languages = [ l for l in Gaffer.Expression.languages() if Gaffer.Expression.defaultExpression( plug, l ) ]
if not languages :
return
menuDefinition.prepend( "/ExpressionDivider", { "divider" : True } )
for language in languages :
menuDefinition.prepend(
"/Create " + IECore.CamelCase.toSpaced( language ) + " Expression...",
{
"command" : functools.partial( __createExpression, plug, language )
}
)
示例15: __clicked
def __clicked( self, button ) :
if Gaffer.readOnly( self.__node["context"] ) :
return
with Gaffer.UndoScope( self.__node.ancestor( Gaffer.ScriptNode ) ) :
self.__node["context"].addChild( Gaffer.NameValuePlug( "", "", True, "member1", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )