本文整理汇总了Python中Gaffer.readOnly方法的典型用法代码示例。如果您正苦于以下问题:Python Gaffer.readOnly方法的具体用法?Python Gaffer.readOnly怎么用?Python Gaffer.readOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaffer
的用法示例。
在下文中一共展示了Gaffer.readOnly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCopyPaste
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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"] ) )
示例2: _popupMenu
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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() ),
} )
示例3: __init__
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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: testReadOnly
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
def testReadOnly(self):
n = GafferTest.AddNode()
self.assertEqual(Gaffer.getReadOnly(n), False)
self.assertEqual(Gaffer.getReadOnly(n["op1"]), False)
self.assertEqual(Gaffer.readOnly(n), False)
self.assertEqual(Gaffer.readOnly(n["op1"]), False)
Gaffer.setReadOnly(n["op1"], True)
self.assertEqual(Gaffer.getReadOnly(n), False)
self.assertEqual(Gaffer.getReadOnly(n["op1"]), True)
self.assertEqual(Gaffer.readOnly(n), False)
self.assertEqual(Gaffer.readOnly(n["op1"]), True)
Gaffer.setReadOnly(n, True)
self.assertEqual(Gaffer.getReadOnly(n), True)
self.assertEqual(Gaffer.getReadOnly(n["op1"]), True)
self.assertEqual(Gaffer.readOnly(n), True)
self.assertEqual(Gaffer.readOnly(n["op1"]), True)
Gaffer.setReadOnly(n["op1"], False)
self.assertEqual(Gaffer.getReadOnly(n), True)
self.assertEqual(Gaffer.getReadOnly(n["op1"]), False)
self.assertEqual(Gaffer.readOnly(n), True)
self.assertEqual(Gaffer.readOnly(n["op1"]), True)
示例5: __menuDefinition
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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
示例6: __namesPopupMenu
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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,
}
)
示例7: _updateFromPlug
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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 ) )
示例8: applyDefaults
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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 )
示例9: __nodeGraphPlugContextMenu
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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 ),
}
)
示例10: __clicked
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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 ) )
示例11: __popupMenu
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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 )
}
)
示例12: __clicked
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
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 )
示例13: __setsPopupMenu
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
def __setsPopupMenu( menuDefinition, plugValueWidget ) :
plug = plugValueWidget.getPlug()
if plug is None :
return
acceptsSetName = Gaffer.Metadata.value( plug, "ui:scene:acceptsSetName" )
acceptsSetNames = Gaffer.Metadata.value( plug, "ui:scene:acceptsSetNames" )
if not acceptsSetName and not acceptsSetNames :
return
node = plug.node()
if isinstance( node, GafferScene.Filter ) :
nodes = [ o.node() for o in node["out"].outputs() ]
else :
nodes = [ node ]
setNames = set()
with plugValueWidget.getContext() :
for node in nodes :
for scenePlug in node.children( GafferScene.ScenePlug ) :
if scenePlug.direction() != scenePlug.Direction.In :
continue
setNames.update( [ str( n ) for n in scenePlug["setNames"].getValue() ] )
if not setNames :
return
menuDefinition.prepend( "/SetsDivider", { "divider" : True } )
with plugValueWidget.getContext() :
if acceptsSetNames :
currentNames = set( plug.getValue().split() )
else :
currentNames = set( [ plug.getValue() ] )
for setName in reversed( sorted( list( setNames ) ) ) :
newNames = set( currentNames ) if acceptsSetNames else set()
if setName not in currentNames :
newNames.add( setName )
else :
newNames.discard( setName )
menuDefinition.prepend(
"/Sets/%s" % setName,
{
"command" : functools.partial( __setValue, plug, " ".join( sorted( newNames ) ) ),
"checkBox" : setName in currentNames,
"active" : plug.settable() and not plugValueWidget.getReadOnly() and not Gaffer.readOnly( plug ),
}
)
示例14: _updateFromSet
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
def _updateFromSet( self ) :
GafferUI.NodeSetEditor._updateFromSet( self )
del self.__column[:]
self.__nodeUI = None
self.__nameWidget = None
node = self._lastAddedNode()
if not node :
return
with self.__column :
with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, borderWidth=8, spacing=4 ) :
GafferUI.Label( "<h4>Node Name</h4>" )
self.__nameWidget = GafferUI.NameWidget( node )
## \todo Make NameWidget support the readOnly metadata internally itself.
# We can't do that easily right now, because it would need to be managing
# the exact same `setEditable()` call that we're using here to propagate
# our Widget readonlyness. Really our Widget readonlyness mechanism is a
# bit lacking, and it should really be inherited automatically so we don't
# have to propagate it like this.
self.__nameWidget.setEditable( not self.getReadOnly() and not Gaffer.readOnly( node ) )
with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4 ) as infoSection :
GafferUI.Label( "<h4>" + node.typeName().rpartition( ":" )[-1] + "</h4>" )
button = GafferUI.Button( image = "info.png", hasFrame = False )
url = Gaffer.Metadata.value( node, "documentation:url" )
if url :
button.clickedSignal().connect(
lambda button : GafferUI.showURL( url ),
scoped = False
)
toolTip = "<h3>" + node.typeName().rpartition( ":" )[2] + "</h3>"
description = Gaffer.Metadata.nodeDescription( node )
if description :
toolTip += "\n\n" + description
infoSection.setToolTip( toolTip )
GafferUI.MenuButton(
image = "gear.png",
hasFrame = False,
menu = GafferUI.Menu( Gaffer.WeakMethod( self.__menuDefinition ) )
)
frame = GafferUI.Frame( borderStyle=GafferUI.Frame.BorderStyle.None, borderWidth=0 )
self.__column.append( frame, expand=True )
self.__nodeUI = GafferUI.NodeUI.create( node )
self.__nodeUI.setReadOnly( self.getReadOnly() )
frame.setChild( self.__nodeUI )
示例15: appendEnabledPlugMenuDefinitions
# 需要导入模块: import Gaffer [as 别名]
# 或者: from Gaffer import readOnly [as 别名]
def appendEnabledPlugMenuDefinitions( cls, nodeGraph, node, menuDefinition ) :
enabledPlug = node.enabledPlug() if isinstance( node, Gaffer.DependencyNode ) else None
if enabledPlug is not None :
menuDefinition.append( "/EnabledDivider", { "divider" : True } )
menuDefinition.append(
"/Enabled",
{
"command" : functools.partial( cls.__setEnabled, node ),
"checkBox" : enabledPlug.getValue(),
"active" : enabledPlug.settable() and not Gaffer.readOnly( enabledPlug )
}
)