def _run(self, args): if len(args["files"]) < 1 or len(args["files"]) > 2: raise Exception("Must view exactly one file.") self.__window = GafferUI.Window( title="Gaffer Viewer", sizeMode=GafferUI.Window.SizeMode.Manual) self.__window.setChild( GafferUI.CompoundPathPreview( Gaffer.FileSystemPath(args["files"][0]))) self.__closedConnection = self.__window.closedSignal().connect( Gaffer.WeakMethod(self.__closed)) ## \todo The window doesn't appear without this naughtiness. I think we either need to # add a similar method in the public interface, or maybe make a SizeConstraintContainer # or something along those lines. self.__window._qtWidget().setMinimumSize(300, 200) self.__window.setVisible(True) GafferUI.EventLoop.mainEventLoop().start() return 0
def __init__( self, path, previewTypes=[], allowMultipleSelection=False, **kw ) : self.__column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=8 ) GafferUI.Widget.__init__( self, self.__column, **kw ) # we use this temporary path for our child widgets while constructing, and then call # self.setPath() to replace it with the real thing. this lets us avoid duplicating the # logic we need in setPath(). tmpPath = Gaffer.DictPath( {}, "/" ) with self.__column : # row for manipulating current directory with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 0 ) : self.__displayModeButton = GafferUI.Button( image = "pathListingTree.png", hasFrame=False ) self.__displayModeButton.setToolTip( "Toggle between list and tree views" ) self.__displayModeButtonClickedConnection = self.__displayModeButton.clickedSignal().connect( Gaffer.WeakMethod( self.__displayModeButtonClicked ) ) reloadButton = GafferUI.Button( image = "refresh.png", hasFrame=False ) reloadButton.setToolTip( "Refresh view" ) self.__reloadButtonClickedConnection = reloadButton.clickedSignal().connect( Gaffer.WeakMethod( self.__reloadButtonClicked ) ) upButton = GafferUI.Button( image = "pathUpArrow.png", hasFrame=False ) upButton.setToolTip( "Up one level" ) self.__upButtonClickedConnection = upButton.clickedSignal().connect( Gaffer.WeakMethod( self.__upButtonClicked ) ) GafferUI.Spacer( IECore.V2i( 4, 4 ) ) self.__dirPathWidget = GafferUI.PathWidget( tmpPath ) # directory listing and preview widget with GafferUI.SplitContainer( GafferUI.SplitContainer.Orientation.Horizontal, expand=True ) as splitContainer : self.__directoryListing = GafferUI.PathListingWidget( tmpPath, allowMultipleSelection=allowMultipleSelection ) self.__displayModeChangedConnection = self.__directoryListing.displayModeChangedSignal().connect( Gaffer.WeakMethod( self.__displayModeChanged ) ) if len( previewTypes ) : self.__previewWidget = GafferUI.CompoundPathPreview( tmpPath, childTypes=previewTypes ) else : self.__previewWidget = None if len( splitContainer ) > 1 : splitContainer.setSizes( [ 2, 1 ] ) # give priority to the listing over the preview # filter section self.__filterFrame = GafferUI.Frame( borderWidth=0, borderStyle=GafferUI.Frame.BorderStyle.None ) self.__filter = None # path self.__pathWidget = GafferUI.PathWidget( tmpPath ) self.__pathWidget.setVisible( allowMultipleSelection == False ) self.__pathSelectedSignal = GafferUI.WidgetSignal() self.__listingSelectionChangedConnection = self.__directoryListing.selectionChangedSignal().connect( Gaffer.WeakMethod( self.__listingSelectionChanged ) ) self.__listingSelectedConnection = self.__directoryListing.pathSelectedSignal().connect( Gaffer.WeakMethod( self.__pathSelected ) ) self.__pathWidgetSelectedConnection = self.__pathWidget.activatedSignal().connect( Gaffer.WeakMethod( self.__pathSelected ) ) self.__path = None self.setPath( path )
def __init__(self, path, previewTypes=[], allowMultipleSelection=False, bookmarks=None, **kw): self.__column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=8) GafferUI.Widget.__init__(self, self.__column, **kw) # we use this temporary path for our child widgets while constructing, and then call # self.setPath() to replace it with the real thing. this lets us avoid duplicating the # logic we need in setPath(). tmpPath = Gaffer.DictPath({}, "/") with self.__column: with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=4) as browserFrame: # Override this so we can customise the appearance of only this list container browserFrame._qtWidget().setObjectName( "gafferPathListingContainer") # row for manipulating current directory with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4, borderWidth=8): self.__displayModeButton = GafferUI.Button( image="pathListingTree.png", hasFrame=False) self.__displayModeButton.setToolTip( "Toggle between list and tree views") self.__displayModeButton.clickedSignal().connect( Gaffer.WeakMethod(self.__displayModeButtonClicked), scoped=False) self.__bookmarksButton = GafferUI.MenuButton( image="bookmarks.png", hasFrame=False, menu=GafferUI.Menu( Gaffer.WeakMethod(self.__bookmarksMenuDefinition)), ) self.__bookmarksButton.setToolTip("Bookmarks") self.__bookmarksButton.dragEnterSignal().connect( Gaffer.WeakMethod(self.__bookmarksButtonDragEnter), scoped=False) self.__bookmarksButton.dragLeaveSignal().connect( Gaffer.WeakMethod(self.__bookmarksButtonDragLeave), scoped=False) self.__bookmarksButton.dropSignal().connect( Gaffer.WeakMethod(self.__bookmarksButtonDrop), scoped=False) reloadButton = GafferUI.Button(image="refresh.png", hasFrame=False) reloadButton.setToolTip("Refresh view") reloadButton.clickedSignal().connect(Gaffer.WeakMethod( self.__reloadButtonClicked), scoped=False) upButton = GafferUI.Button(image="pathUpArrow.png", hasFrame=False) upButton.setToolTip("Up one level") upButton.clickedSignal().connect(Gaffer.WeakMethod( self.__upButtonClicked), scoped=False) GafferUI.Spacer(imath.V2i(2, 2)) self.__dirPathWidget = GafferUI.PathWidget(tmpPath) # directory listing and preview widget with GafferUI.SplitContainer( GafferUI.SplitContainer.Orientation.Horizontal, parenting={"expand": True}) as splitContainer: self.__directoryListing = GafferUI.PathListingWidget( tmpPath, allowMultipleSelection=allowMultipleSelection) self.__directoryListing.displayModeChangedSignal().connect( Gaffer.WeakMethod(self.__displayModeChanged), scoped=False) if len(previewTypes): self.__previewWidget = GafferUI.CompoundPathPreview( tmpPath, childTypes=previewTypes) else: self.__previewWidget = None if len(splitContainer) > 1: splitContainer.setSizes( [2, 1]) # give priority to the listing over the preview # filter section self.__filterFrame = GafferUI.Frame( borderWidth=4, borderStyle=GafferUI.Frame.BorderStyle.None) self.__filter = None # path self.__pathWidget = GafferUI.PathWidget(tmpPath) self.__pathWidget.setVisible(allowMultipleSelection == False) self.__pathSelectedSignal = GafferUI.WidgetSignal() self.__directoryListing.selectionChangedSignal().connect( Gaffer.WeakMethod(self.__listingSelectionChanged), scoped=False) self.__directoryListing.pathSelectedSignal().connect(Gaffer.WeakMethod( self.__pathSelected), scoped=False) self.__pathWidget.activatedSignal().connect(Gaffer.WeakMethod( self.__pathSelected), scoped=False) self.__path = None self.setPath(path) self.setBookmarks(bookmarks)