Beispiel #1
0
	def __init__( self, plug, **kw ) :

		self.__codeWidget = GafferUI.CodeWidget()

		GafferUI.PlugValueWidget.__init__( self, self.__codeWidget, plug, **kw )

		self.__codeWidget._qtWidget().setPlaceholderText(
			inspect.cleandoc(
				"""
				# Global variables :
				#
				# `context` : Context the command is being executed in.
				# `variables` : Contents of the Variables tab.
				"""
			)
		)

		self.__codeWidget.setHighlighter( GafferUI.CodeWidget.PythonHighlighter() )
		self.__codeWidget.setCommentPrefix( "#" )

		self.__codeWidget.activatedSignal().connect( Gaffer.WeakMethod( self.__setPlugValue ), scoped = False )
		self.__codeWidget.editingFinishedSignal().connect( Gaffer.WeakMethod( self.__setPlugValue ), scoped = False )

		node = self.__pythonCommandNode()
		if node is not None :
			node.plugDirtiedSignal().connect( Gaffer.WeakMethod( self.__pythonCommandPlugDirtied ), scoped = False )
		self.__updateCompleter()

		self._updateFromPlug()
Beispiel #2
0
	def __init__( self, plug, **kw ) :

		self.__codeWidget = GafferUI.CodeWidget()

		GafferUI.PlugValueWidget.__init__( self, self.__codeWidget, plug, **kw )

		self.__codeWidget.setHighlighter( _CodeWidget._Highlighter() )
		self.__codeWidget.setCommentPrefix( "//" )

		self._addPopupMenu( self.__codeWidget )

		self.__codeWidget.activatedSignal().connect( Gaffer.WeakMethod( self.__setPlugValue ), scoped = False )
		self.__codeWidget.editingFinishedSignal().connect( Gaffer.WeakMethod( self.__setPlugValue ), scoped = False )
		self.__codeWidget.dropTextSignal().connect( Gaffer.WeakMethod( self.__dropText ), scoped = False )

		self._updateFromPlug()
Beispiel #3
0
    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.MetadataAlgo.readOnly(node))

            self.__textWidget = GafferUI.CodeWidget()
            self.__textWidget.setEditable(
                not Gaffer.MetadataAlgo.readOnly(node))

            self.__textWidget.activatedSignal().connect(Gaffer.WeakMethod(
                self.__activated),
                                                        scoped=False)
            self.__textWidget.editingFinishedSignal().connect(
                Gaffer.WeakMethod(self.__editingFinished), scoped=False)
            self.__textWidget.dropTextSignal().connect(Gaffer.WeakMethod(
                self.__dropText),
                                                       scoped=False)
            self.__textWidget.contextMenuSignal().connect(Gaffer.WeakMethod(
                self.__expressionContextMenu),
                                                          scoped=False)

            self.__messageWidget = GafferUI.MessageWidget()

        self.__node.expressionChangedSignal().connect(Gaffer.WeakMethod(
            self.__expressionChanged),
                                                      scoped=False)
        self.__node.errorSignal().connect(Gaffer.WeakMethod(self.__error),
                                          scoped=False)

        self.__update()
Beispiel #4
0
    def __init__(self, scriptNode, **kw):

        self.__splittable = GafferUI.SplitContainer(borderWidth=2)

        GafferUI.Editor.__init__(self, self.__splittable, scriptNode, **kw)

        self.__outputWidget = GafferUI.MultiLineTextWidget(
            editable=False,
            wrapMode=GafferUI.MultiLineTextWidget.WrapMode.None_,
            role=GafferUI.MultiLineTextWidget.Role.Code,
        )
        self.__outputWidget.contextMenuSignal().connect(Gaffer.WeakMethod(
            self.__contextMenu),
                                                        scoped=False)

        self.__inputWidget = GafferUI.CodeWidget()

        self.__splittable.append(self.__outputWidget)
        self.__splittable.append(self.__inputWidget)

        self.__inputWidget.activatedSignal().connect(Gaffer.WeakMethod(
            self.__activated),
                                                     scoped=False)
        self.__inputWidget.dropTextSignal().connect(Gaffer.WeakMethod(
            self.__dropText),
                                                    scoped=False)
        self.__inputWidget.contextMenuSignal().connect(Gaffer.WeakMethod(
            self.__contextMenu),
                                                       scoped=False)
        GafferUI.WidgetAlgo.joinEdges(
            [self.__outputWidget, self.__inputWidget],
            orientation=GafferUI.ListContainer.Orientation.Vertical)

        self.__executionDict = {
            "imath": imath,
            "IECore": IECore,
            "Gaffer": Gaffer,
            "GafferUI": GafferUI,
            "root": scriptNode,
        }
        self.__inputWidget.setCompleter(
            GafferUI.CodeWidget.PythonCompleter(self.__executionDict))
        self.__inputWidget.setHighlighter(
            GafferUI.CodeWidget.PythonHighlighter())
        self.__inputWidget.setCommentPrefix("#")