def __init__(self, title, message=None, details=None, messages=None, closeLabel="Close", **kw): GafferUI.Dialogue.__init__(self, title, sizeMode=GafferUI.Window.SizeMode.Manual, **kw) with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=8) as column: GafferUI.Image("failure.png", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center, "expand": True, }) GafferUI.Spacer(imath.V2i(250, 1)) if message is not None: GafferUI.Label( "<b>" + IECore.StringUtil.wrap(message, 60).replace("\n", "<br>") + "</b>", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center }) if messages is not None: messageWidget = GafferUI.MessageWidget() for m in messages: messageWidget.messageHandler().handle( m.level, m.context, m.message) if details is not None: with GafferUI.Collapsible(label="Details", collapsed=True): GafferUI.MultiLineTextWidget( text=details, editable=False, ) self._setWidget(column) self.__closeButton = self._addButton(closeLabel)
def setIcon( self, imageOrImageFileName ) : if isinstance( imageOrImageFileName, six.string_types ) : self.__image = GafferUI.Image( imageOrImageFileName ) else : self.__image = imageOrImageFileName self._qtWidget().setWindowIcon( QtGui.QIcon( self.__image._qtPixmap() ) )
def __buildAction( self, item, name, parent ) : label = name with IECore.IgnoredExceptions( AttributeError ) : label = item.label qtAction = QtWidgets.QAction( label, parent ) qtAction.__item = item if item.checkBox is not None : qtAction.setCheckable( True ) checked = self.__evaluateItemValue( item.checkBox ) qtAction.setChecked( checked ) if item.divider : qtAction.setSeparator( True ) if item.command : if item.checkBox : signal = qtAction.toggled[bool] else : signal = qtAction.triggered[bool] if self.__searchable : signal.connect( IECore.curry( Gaffer.WeakMethod( self.__menuActionTriggered ), qtAction ) ) signal.connect( IECore.curry( Gaffer.WeakMethod( self.__actionTriggered ), weakref.ref( qtAction ) ) ) active = self.__evaluateItemValue( item.active ) qtAction.setEnabled( active ) shortCut = getattr( item, "shortCut", None ) if shortCut is not None : qtAction.setShortcuts( [ QtGui.QKeySequence( s.strip() ) for s in shortCut.split( "," ) ] ) # If we allow shortcuts to be created at the window level (the default), # then we can easily get into a situation where our shortcuts conflict # with those of the host when embedding our MenuBars in an application like Maya. # Here we're limiting the scope so that conflicts don't occur, deferring # to the code in MenuBar to manage triggering of the action with manual # shortcut processing. qtAction.setShortcutContext( QtCore.Qt.WidgetShortcut ) # when an icon file path is defined in the menu definition icon = getattr( item, "icon", None ) if icon is not None : if isinstance( icon, basestring ) : image = GafferUI.Image( icon ) else : assert( isinstance( icon, GafferUI.Image ) ) image = icon qtAction.setIcon( QtGui.QIcon( image._qtPixmap() ) ) if item.description : qtAction.setStatusTip( item.description ) return qtAction
def __buildAction(self, item, name, parent, activeOverride=None): label = name with IECore.IgnoredExceptions(AttributeError): label = item.label qtAction = QtGui.QAction(label, parent) qtAction.__item = item if item.checkBox is not None: qtAction.setCheckable(True) checked = self.__evaluateItemValue(item.checkBox) qtAction.setChecked(checked) if item.divider: qtAction.setSeparator(True) if item.command: if item.checkBox: signal = qtAction.toggled[bool] else: signal = qtAction.triggered[bool] if self.__searchable: signal.connect( IECore.curry(Gaffer.WeakMethod(self.__menuActionTriggered), qtAction)) signal.connect( IECore.curry(Gaffer.WeakMethod(self.__actionTriggered), weakref.ref(qtAction))) active = item.active if activeOverride is None else activeOverride active = self.__evaluateItemValue(active) qtAction.setEnabled(active) shortCut = getattr(item, "shortCut", None) if shortCut is not None: qtAction.setShortcuts( [QtGui.QKeySequence(s.strip()) for s in shortCut.split(",")]) # when an icon file path is defined in the menu definition icon = getattr(item, "icon", None) if icon is not None: if isinstance(icon, basestring): image = GafferUI.Image(icon) else: assert (isinstance(icon, GafferUI.Image)) image = icon qtAction.setIcon(QtGui.QIcon(image._qtPixmap())) if item.description: qtAction.setStatusTip(item.description) return qtAction
def setImage( self, imageOrImageFileName ) : assert( isinstance( imageOrImageFileName, ( basestring, GafferUI.Image, type( None ) ) ) ) if isinstance( imageOrImageFileName, basestring ) : self.__image = GafferUI.Image( imageOrImageFileName ) else : self.__image = imageOrImageFileName self.__updateIcon()
def __initiateResultDisplay( self, result ) : # Although we computed a result successfully, there may still be minor problems # indicated by messages the Op emitted - check for those. problems = [] for level in ( IECore.Msg.Level.Error, IECore.Msg.Level.Warning ) : count = self.__messageWidget.messageCount( level ) if count : problems.append( "%d %s%s" % ( count, IECore.Msg.levelAsString( level ).capitalize(), "s" if count > 1 else "" ) ) if not problems : # If there were no problems, then our post execute behaviour may # indicate that we don't need to display anything - deal with # those cases. if self.__postExecuteBehaviour == self.PostExecuteBehaviour.Close : self.__close() return elif self.__postExecuteBehaviour == self.PostExecuteBehaviour.None_ : self.__initiateParameterEditing() return # Either the post execute behaviour says we should display the result, or we're # going to anyway, because we don't want the problems to go unnoticed. self.__progressIconFrame.setChild( GafferUI.Image( "successWarning.png" if problems else "success.png" ) ) completionMessage = "Completed" if problems : completionMessage += " with " + " and ".join( problems ) self.__messageCollapsible.setCollapsed( False ) self.__progressLabel.setText( "<h3>" + completionMessage + "</h3>" ) self.__messageWidget.messageHandler().handle( IECore.Msg.Level.Info, "Result", str( result ) ) self.__backButton.setText( "Close" ) self.__backButton.setEnabled( True ) self.__backButton.setVisible( True ) self.__backButtonClickedConnection = self.__backButton.clickedSignal().connect( Gaffer.WeakMethod( self.__close ) ) self.__forwardButton.setText( "Again!" ) self.__forwardButton.setEnabled( True ) self.__forwardButton.setVisible( True ) self.__forwardButtonClickedConnection = self.__forwardButton.clickedSignal().connect( Gaffer.WeakMethod( self.__initiateParameterEditing ) ) if self.__postExecuteBehaviour in ( self.PostExecuteBehaviour.DisplayResultAndClose, self.PostExecuteBehaviour.Close ) : self.__forwardButton.setVisible( False ) self.__frame.setChild( self.__progressUI ) self.__backButton._qtWidget().setFocus() self.__state = self.__State.ResultDisplay
def __init__(self, tool, **kw): GafferUI.Frame.__init__(self, borderWidth=4, **kw) self.__tool = tool with self: with GafferUI.ListContainer(orientation=GafferUI.ListContainer. Orientation.Horizontal) as self.__row: self.__infoIcon = GafferUI.Image("infoSmall.png") self.__errorIcon = GafferUI.Image("errorNotificationSmall.png") self.__warningIcon = GafferUI.Image("warningSmall.png") GafferUI.Spacer(size=imath.V2i(4), maximumSize=imath.V2i(4)) self.__label = GafferUI.Label("") self.__tool.statusChangedSignal().connect(Gaffer.WeakMethod( self.__update, fallbackResult=None), scoped=False) self.__update()
def __init__(self, tool, **kw): GafferUI.Frame.__init__(self, borderWidth=4, **kw) self.__tool = tool with self: with GafferUI.ListContainer(orientation=GafferUI.ListContainer. Orientation.Horizontal) as self.__row: self.__infoIcon = GafferUI.Image("infoSmall.png") self.__errorIcon = GafferUI.Image("errorSmall.png") self.__warningIcon = GafferUI.Image("warningSmall.png") GafferUI.Spacer(size=imath.V2i(4), maximumSize=imath.V2i(4)) self.__label = GafferUI.Label("") GafferUI.Spacer(size=imath.V2i(8), maximumSize=imath.V2i(8)) GafferUI.Divider( orientation=GafferUI.Divider.Orientation.Vertical) GafferUI.Spacer(size=imath.V2i(8), maximumSize=imath.V2i(8)) with GafferUI.ListContainer( orientation=GafferUI.ListContainer.Orientation. Horizontal) as self.__controls: self.__enabledLabel = GafferUI.Label("Enabled") self.__enabled = GafferUI.BoolPlugValueWidget(None) self.__enabled.boolWidget().setDisplayMode( GafferUI.BoolWidget.DisplayMode.Switch) button = GafferUI.Button("Reset") button._qtWidget().setFixedWidth(50) button.clickedSignal().connect(Gaffer.WeakMethod( self.__buttonClicked), scoped=False) self.__tool.statusChangedSignal().connect(Gaffer.WeakMethod( self.__update, fallbackResult=None), scoped=False) self.__update()
def _deferredUpdate(self, op): del self.__column[:] self.jobs = populateJobs() if str(op) == '/': return job = str(op).split('/')[-1] jobIndex = job[:4] jobName = job[5:] self.__node["parameters"]["jobIndex"].setValue(int(jobIndex)) self.__node["parameters"]["jobName"].setValue(jobName) self.__node["parameters"]["assets"].setValue( IECore.StringVectorData([])) if self.jobs[job].has_key('assets'): assets = self.jobs[job]['assets'].keys() assets.sort() self.__node["parameters"]["assets"].setValue( IECore.StringVectorData(assets)) self.__node["parameters"]["shots"].setValue(IECore.StringVectorData( [])) if self.jobs[job].has_key('shots'): shots = self.jobs[job]['shots'].keys() shots.sort() self.__node["parameters"]["shots"].setValue( IECore.StringVectorData(shots)) self.__node["parameters"]["client"].setValue('') if self.jobs[job].has_key('client'): self.__node["parameters"]["client"].setValue( self.jobs[job]['client']) self.__node["parameters"]["defaultOutput"].setValue('') jobData = pipe.admin.job( self.__node["parameters"]["jobIndex"].getValue(), self.__node["parameters"]["jobName"].getValue(), ).getData() if jobData.has_key('output'): self.__node["parameters"]["defaultOutput"].setValue( jobData['output']) with self.__column: GafferUI.Image("%s/opa.png" % pipe.name()) GafferUI.NodeUI.create(self.__node) button = GafferUI.Button("Execute") self.__executeClickedConnection = button.clickedSignal().connect( self.__executeClicked)
def setImage(self, image): if isinstance(image, basestring): self.__image = GafferUI.Image(image) else: assert (isinstance(image, (GafferUI.Image, type(None)))) self.__image = image if self.__image is None: self._qtWidget().setIcon(QtGui.QIcon()) else: self._qtWidget().setIcon(QtGui.QIcon(self.__image._qtPixmap())) self._qtWidget().setIconSize(self.__image._qtPixmap().size())
def __init__(self, plug, **kw): self.__row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4) GafferUI.PlugValueWidget.__init__(self, self.__row, plug, **kw) with self.__row: GafferUI.PlugValueWidget.create(plug["out"]) GafferUI.Image("shuffleArrow.png") GafferUI.PlugValueWidget.create(plug["in"])
def setIcon(self, index, imageOrImageFileName): icon = None assert (isinstance(imageOrImageFileName, (basestring, GafferUI.Image, type(None)))) if isinstance(imageOrImageFileName, basestring): icon = GafferUI.Image(imageOrImageFileName) else: icon = imageOrImageFileName if icon is not None: self._qtWidget().setItemIcon(index, QtGui.QIcon(icon._qtPixmap())) self._qtWidget().setIconSize(icon._qtPixmap().size())
def __init__(self, title, **kw): GafferUI.Dialogue.__init__(self, title, **kw) # Build UI. We have widgets for two states - busy and error - and manage # widget visibility to switch between those states. with GafferUI.ListContainer(spacing=4) as column: GafferUI.Spacer(imath.V2i(250, 20)) self.__busyWidget = GafferUI.BusyWidget( parenting={ "horizontalAlignment": GafferUI.ListContainer.HorizontalAlignment.Center }) self.__errorImage = GafferUI.Image( "failure.png", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center, "expand": True, }) self.__label = GafferUI.Label( parenting={ "horizontalAlignment": GafferUI.ListContainer.HorizontalAlignment.Center }) GafferUI.Spacer(imath.V2i(250, 20)) self.__messageWidget = GafferUI.MessageWidget(toolbars=True) self._setWidget(column) self.__continueButton = self._addButton("Continue") self.__cancelButton = self._addButton("Cancel") # Make it impossible to accidentally cancel by hitting `Enter`. self.__cancelButton._qtWidget().setFocusPolicy(QtCore.Qt.NoFocus) self.__cancelButton.clickedSignal().connect(Gaffer.WeakMethod( self.__cancelClicked), scoped=False) self.keyPressSignal().connect(Gaffer.WeakMethod(self.__keyPress), scoped=False) self.__backgroundTask = None self.__messageHandler = IECore.CapturingMessageHandler()
def __init__( self, type, **kw ) : GafferUI.ListContainer.__init__( self, **kw ) with self : if type != self.Type.Top and type != self.Type.Single : image = GafferUI.Image( "railLine.png" ) ## \todo Decide how we do this via the public API. # Perhaps by putting the image in a Sizer? Or by # adding stretch methods to the Image class? image._qtWidget().setSizePolicy( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred ) image._qtWidget().setScaledContents( True ) else : GafferUI.Spacer( IECore.V2i( 1 ) ) GafferUI.Image( "rail" + str( type ) + ".png" ) if type != self.Type.Bottom and type != self.Type.Single : image = GafferUI.Image( "railLine.png" ) image._qtWidget().setSizePolicy( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred ) image._qtWidget().setScaledContents( True ) else : GafferUI.Spacer( IECore.V2i( 1 ) )
def __init__(self, tool, **kw): GafferUI.Frame.__init__(self, borderWidth=4, **kw) self.__tool = tool with self: with GafferUI.ListContainer( orientation=GafferUI.ListContainer.Orientation.Horizontal, spacing=8): with GafferUI.ListContainer( orientation=GafferUI.ListContainer.Orientation. Horizontal) as self.__infoRow: GafferUI.Image("infoSmall.png") GafferUI.Spacer(size=imath.V2i(4), maximumSize=imath.V2i(4)) self.__infoLabel = GafferUI.Label("") self.__nameLabel = GafferUI.NameLabel( graphComponent=None, numComponents=sys.maxsize) self.__nameLabel.setFormatter(_boldFormatter) self.__nameLabel.buttonDoubleClickSignal().connect( Gaffer.WeakMethod(self.__buttonDoubleClick), scoped=False) with GafferUI.ListContainer(orientation=GafferUI.ListContainer. Orientation.Horizontal, spacing=4) as self.__warningRow: GafferUI.Image("warningSmall.png") self.__warningLabel = GafferUI.Label("") self.__tool.selectionChangedSignal().connect(Gaffer.WeakMethod( self.__update, fallbackResult=None), scoped=False) self.__update()
def __init__( self, parameterHandler, **kw ) : self.__row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) GafferUI.PlugValueWidget.__init__( self, self.__row, parameterHandler.plug(), **kw ) self.__row.append( GafferUI.Image( "collapsibleArrowDownHover.png" ) ) self.__label = GafferUI.Label( "" ) self.__row.append( self.__label ) self._addPopupMenu( buttons = GafferUI.ButtonEvent.Buttons.All ) self.__parameterHandler = parameterHandler self._updateFromPlug()
def __init__( self, tableView, **kw ) : row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) GafferUI.Widget.__init__( self, row, **kw ) with row : self.__results = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) with self.__results : self.__resultCount = GafferUI.Label() self.__prevButton = GafferUI.Button( image = "arrowLeft10.png", hasFrame = False ) self.__prevButton.clickedSignal().connect( Gaffer.WeakMethod( self.__buttonClicked ), scoped = False ) self.__nextButton = GafferUI.Button( image = "arrowRight10.png", hasFrame = False ) self.__nextButton.clickedSignal().connect( Gaffer.WeakMethod( self.__buttonClicked ), scoped = False ) self.__focusButton = GafferUI.Button( image = "searchFocusOff.png", hasFrame = False ) self.__focusButton.clickedSignal().connect( Gaffer.WeakMethod( self.__buttonClicked ), scoped = False ) self.__searchField = GafferUI.TextWidget() # Edited catches focus-out and makes sure we update the search text self.__searchField.editingFinishedSignal().connect( Gaffer.WeakMethod( self.__textEdited ), scoped = False ) # Activated allows <enter> to repeatedly jump to the next search result self.__searchField.activatedSignal().connect( Gaffer.WeakMethod( self.__textActivated ), scoped = False ) self.__searchField._qtWidget().setObjectName( "gafferSearchField" ) self.__searchField._qtWidget().setPlaceholderText( "Search" ) self.__searchField._qtWidget().setMaximumWidth( 250 ) self.__prevButton.setToolTip( "Show previous match [P]" ) self.__nextButton.setToolTip( "Show next match [N]" ) # Though Qt provides clearButtonEnabled(), this seems to be missing its icon on macOS, resulting in a # clickable-but-not-visible clear button. As such we need to make our own. Icons need to be 16x16 exactly. clearImage = GafferUI.Image( "clearSearch.png" ) self.__clearAction = QtWidgets.QAction( clearImage._qtIcon(), "Clear Search", None ) self.__clearAction.triggered.connect( Gaffer.WeakMethod( self.__clear ) ) self.__searchField._qtWidget().addAction( self.__clearAction, QtWidgets.QLineEdit.TrailingPosition ) self.__table = weakref.ref( tableView ) tableView.searchTextChangedSignal().connect( Gaffer.WeakMethod( self.__searchTextChanged ), scoped = False ) tableView.focusSearchResultsChangedSignal().connect( Gaffer.WeakMethod( self.__focusSearchResultsChanged ), scoped = False ) tableView.searchResultsChangedSignal().connect( Gaffer.WeakMethod( self.__searchResultsChanged ), scoped = False ) self.__searchTextChanged( tableView ) self.__focusSearchResultsChanged( tableView ) self.__searchResultsChanged( tableView )
def pipeImage(op): if type(op) == type(''): opName = op else: opName = op.path opImage = "%s/opa.png" % pipe.name() if opName: import os image = "%s/opa_%s.png" % (pipe.name(), '_'.join( opName.split('/')).replace('%s' % pipe.name(), '')) search = IECore.SearchPath(os.environ.get("GAFFERUI_IMAGE_PATHS", ""), ":") image = search.find(image) if image: opImage = image return GafferUI.Image(opImage)
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) self.__nameWidget.setEditable(not self.getReadOnly()) with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4) as infoSection: GafferUI.Label("<h4>" + node.typeName().rpartition(":")[-1] + "</h4>") GafferUI.Image("info.png") 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)
def __init__(self, title, message, details=None, **kw): GafferUI.Dialogue.__init__(self, title, sizeMode=GafferUI.Window.SizeMode.Manual, **kw) with GafferUI.Frame() as frame: with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=8) as column: GafferUI.Spacer(IECore.V2i(1), parenting={"expand": True}) GafferUI.Image("failure.png", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center, "expand": True, }) GafferUI.Spacer(IECore.V2i(250, 1), parenting={"expand": True}) GafferUI.Label( "<b>" + IECore.StringUtil.wrap(message, 60).replace("\n", "<br>") + "</b>", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center }) if details is not None: with GafferUI.Collapsible(label="Details", collapsed=True): GafferUI.MultiLineTextWidget( text=details, editable=False, ) self._setWidget(frame) self.__closeButton = self._addButton("Close")
def testAccessors(self): b = GafferUI.Button() b.setText("a") self.assertEqual(b.getText(), "a") i = GafferUI.Image("arrowRight10.png") b.setImage(i) self.assertTrue(b.getImage() is i) b.setImage("arrowRight10.png") self.assertIsInstance(b.getImage(), GafferUI.Image) b.setImage(None) self.assertEqual(b.getImage(), None) self.assertEqual(b.getHasFrame(), True) b.setHasFrame(False) self.assertEqual(b.getHasFrame(), False)
def __initiateResultDisplay(self): # Although we computed a result successfully, there may still be minor problems # indicated by messages emitted - check for those. problems = [] for level in (IECore.Msg.Level.Error, IECore.Msg.Level.Warning): count = self.__messageWidget.messageCount(level) if count: problems.append( "%d %s%s" % (count, IECore.Msg.levelAsString(level).capitalize(), "s" if count > 1 else "")) if not problems and self.__postDispatchBehaviour == self.PostDispatchBehaviour.Close: self.close() return self.__progressIconFrame.setChild( GafferUI.Image( "successWarning.png" if problems else "success.png")) completionMessage = "Completed" if problems: completionMessage += " with " + " and ".join(problems) self.__messageCollapsible.setCollapsed(False) self.__progressLabel.setText("<h3>" + completionMessage + "</h3>") self.__messageCollapsible.setVisible( self.__messageWidget.messageCount()) self.__backButton.setEnabled(True) self.__backButton.setVisible(True) self.__primaryButton.setText("Ok") self.__primaryButton.setEnabled(True) self.__primaryButton.setVisible(True) self.__primaryButtonConnection = self.__primaryButton.clickedSignal( ).connect(Gaffer.WeakMethod(self.__close)) self.__primaryButton._qtWidget().setFocus()
def __initiateErrorDisplay(self, exceptionInfo): self.__progressIconFrame.setChild( GafferUI.Image("opDialogueFailure.png")) self.__progressLabel.setText("<h3>Failed</h3>") self.__messageCollapsible.setCollapsed(False) self.__backButton.setVisible(True) self.__backButton.setText("Cancel") self.__backButton.setEnabled(True) self.__backButtonClickedConnection = self.__backButton.clickedSignal( ).connect(Gaffer.WeakMethod(self.__close)) self.__forwardButton.setVisible(True) self.__forwardButton.setText("Retry") self.__forwardButton.setEnabled(True) self.__forwardButtonClickedConnection = self.__forwardButton.clickedSignal( ).connect(Gaffer.WeakMethod(self.__initiateParameterEditing)) self.__messageWidget.messageHandler().handle( IECore.Msg.Level.Debug, "Python Traceback", "".join(traceback.format_exception(*exceptionInfo))) self.__messageWidget.messageHandler().handle( IECore.Msg.Level.Error, "Problem Executing {opName}".format( opName=self.__node.getParameterised()[0].typeName()), str(exceptionInfo[1]), ) self.__frame.setChild(self.__progressUI) self.__forwardButton._qtWidget().setFocus() self.__state = self.__State.ErrorDisplay
def __init__(self, plug, **kw): l = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4) GafferUI.PlugValueWidget.__init__(self, l, plug, **kw) mode = plug["mode"].getValue() with l: self.__indexLabel = GafferUI.Label() labelFont = QtGui.QFont(self.__indexLabel._qtWidget().font()) labelFont.setBold(True) labelFont.setPixelSize(10) labelFontMetrics = QtGui.QFontMetrics(labelFont) self.__indexLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("99")) self.__modeImage = GafferUI.Image("sourceCursor.png") self.__positionLabel = GafferUI.Label() self.__positionLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("9999 9999 -> 9999 9999")) self.__swatch = GafferUI.ColorSwatch() self.__swatch._qtWidget().setFixedWidth(12) self.__swatch._qtWidget().setFixedHeight(12) self.__busyWidget = GafferUI.BusyWidget(size=12) self.__rgbLabel = GafferUI.Label() self.__rgbLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("RGBA : 99999 99999 99999 99999")) self.__hsvLabel = GafferUI.Label() self.__hsvLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("HSV : 99999 99999 99999")) self.__exposureLabel = GafferUI.Label() self.__exposureLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("EV : 19.9")) l.addChild(GafferUI.Spacer(size=imath.V2i(0))) if mode == GafferImageUI.ImageView.ColorInspectorPlug.Mode.Cursor: m = IECore.MenuDefinition() m.append( "/Pixel Inspector", { "command": functools.partial( Gaffer.WeakMethod(self.__addClick), GafferImageUI. ImageView.ColorInspectorPlug.Mode.Pixel) }) m.append( "/Area Inspector", { "command": functools.partial( Gaffer.WeakMethod(self.__addClick), GafferImageUI. ImageView.ColorInspectorPlug.Mode.Area) }) button = GafferUI.MenuButton("", "plus.png", hasFrame=False, menu=GafferUI.Menu( m, title="Add Color Inspector")) else: button = GafferUI.Button("", "delete.png", hasFrame=False) button.clickedSignal().connect(Gaffer.WeakMethod( self.__deleteClick), scoped=False) self.__pixel = imath.V2i(0) self.__createInspectorStartPosition = None if plug.getName() == "ColorInspectorPlug": viewportGadget = plug.node().viewportGadget() imageGadget = viewportGadget.getPrimaryChild() imageGadget.mouseMoveSignal().connect(Gaffer.WeakMethod( self.__mouseMove), scoped=False) imageGadget.buttonPressSignal().connect(Gaffer.WeakMethod( self.__buttonPress), scoped=False) imageGadget.buttonReleaseSignal().connect(Gaffer.WeakMethod( self.__buttonRelease), scoped=False) imageGadget.dragBeginSignal().connect(Gaffer.WeakMethod( self.__dragBegin), scoped=False) imageGadget.dragEnterSignal().connect(Gaffer.WeakMethod( self.__dragEnter), scoped=False) imageGadget.dragMoveSignal().connect(Gaffer.WeakMethod( self.__dragMove), scoped=False) imageGadget.dragEndSignal().connect(Gaffer.WeakMethod( self.__dragEnd), scoped=False) self.__swatch.buttonPressSignal().connect(Gaffer.WeakMethod( self.__buttonPress), scoped=False) self.__swatch.dragBeginSignal().connect(Gaffer.WeakMethod( self.__dragBegin), scoped=False) self.__swatch.dragEndSignal().connect(Gaffer.WeakMethod( self.__dragEnd), scoped=False) plug.node()["colorInspector"]["evaluator"]["pixelColor"].getInput( ).node().plugDirtiedSignal().connect(Gaffer.WeakMethod( self.__updateFromImageNode), scoped=False) plug.node().plugDirtiedSignal().connect(Gaffer.WeakMethod( self._plugDirtied), scoped=False) plug.node()["in"].getInput().node().scriptNode().context( ).changedSignal().connect(Gaffer.WeakMethod(self.__updateFromContext), scoped=False) Gaffer.Metadata.plugValueChangedSignal(self.getPlug().node()).connect( Gaffer.WeakMethod(self.__plugMetadataChanged), scoped=False) self.__updateLabels(imath.V2i(0), imath.Color4f(0, 0, 0, 1)) # Set initial state of mode icon self._plugDirtied(plug["mode"])
def testUnicode( self ) : i = GafferUI.Image( u"info.png" )
def __init__(self, about, **kw): GafferUI.Window.__init__(self, title="About " + about.name(), sizeMode=GafferUI.Window.SizeMode.Manual, borderWidth=6, **kw) self.__linkActivatedConnections = [] with self: with GafferUI.TabbedContainer(): with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=10, borderWidth=10, parenting={"label": "Gaffer"}, ): GafferUI.Spacer(imath.V2i(1), parenting={"expand": True}) GafferUI.Image("GafferLogo.png", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center }) text = "<h3><a href='%s'>%s</a></h3> <small>Version %s</small>" % ( about.url(), about.url(), about.versionString(), ) self.__label( text, horizontalAlignment=GafferUI.HorizontalAlignment. Center, parenting={ "horizontalAlignment": GafferUI.Label.HorizontalAlignment.Center }, ) GafferUI.Spacer(imath.V2i(1), parenting={"expand": True}) self.__label( "<small>%s</small>" % about.copyright().replace("(c)", "©"), parenting={ "horizontalAlignment": GafferUI.Label.HorizontalAlignment.Center }, ) with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=10, borderWidth=10, parenting={"label": "License"}, ): license = "".join( open(os.path.expandvars(about.license())).readlines()) with GafferUI.ScrolledContainer( horizontalMode=GafferUI.ScrollMode.Never, verticalMode=GafferUI.ScrollMode.Automatic, borderWidth=5): self.__label("<pre>" + license + "</pre>") dependencies = about.dependencies() if dependencies: with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=10, borderWidth=10, parenting={"label": "Dependencies"}, ): with GafferUI.ScrolledContainer( horizontalMode=GafferUI.ScrollMode.Never, verticalMode=GafferUI.ScrollMode.Always, borderWidth=5): with GafferUI.ListContainer(GafferUI.ListContainer. Orientation.Vertical, spacing=5, borderWidth=10): text = "<p>%s</p>" % self.__wrapText( about.dependenciesPreamble()) for d in dependencies: text += "<h3>%s</h3>" % d["name"] if "credit" in d: text += "<p>%s</p>" % self.__wrapText( d["credit"]) if "license" in d: text += "<a href='file://%s'>License</a>" % os.path.expandvars( d["license"]) if "url" in d: if "license" in d: text += " | " text += "<a href='%s'>%s</a>" % ( d["url"], d["url"]) self.__label(text)