Cortex  10.0.0-a4
Classes | Public Member Functions | List of all members
IECoreMaya.FileBrowser Class Reference

The Browser class provides a file picker interface within a Maya formLayout. More...

+ Inheritance diagram for IECoreMaya.FileBrowser:

Classes

class  DirectoriesOnlyFilter
 A simple filter that only shows or validates directories. More...
 
class  FnMatchFilter
 A filter that matches a pattern to the filenames. More...
 

Public Member Functions

def __init__ (self, uiParent=None, options=None, filter=None, validate=None, showHidden=False, buttonTitle="Select", withCancel=True, cancelButtonTitle="Cancel", allowMultiSelection=False, saveMode=False, rightHanded=False)
 
def setPath
 Sets the working path for the file browser. More...
 
def getCurrentSelection (self)
 This function should be used to query the users selection in clases using an instance of the FileDialog. More...
 
- Public Member Functions inherited from IECoreMaya.UIElement
def __init__ (self, topLevelUI)
 Derived classes must create a ui element which is the parent of the rest of their ui, and call this init function passing it as the topLevelUI parameter. More...
 
def parent (self)
 Returns the UIElement which forms the parent for this one. More...
 

Signals

! These signals will be emitted in response to user actions.

Classes using the FileDialog should connect to these signals in order to act upon the user's selection. ! {

def selectSignal (self)
 This will be called when the user has selected one or more items. More...
 
def cancelSignal (self)
 This will be emitted if the user clicks the Cancel button. More...
 
def pathChangedSignal (self)
 This will be emitted whenever the current directory has changed as a result of the user browsing around the file system. More...
 
def setButtonTitle (self, title)
 Sets the title of the main button.
 
def getButtonTitle (self, title)
 
def setCancelButtonTitle (self, title)
 Sets the title of the Cancel button, if one exists.
 
def getCancelButtonTitle (self, title)
 

Additional Inherited Members

- Static Public Member Functions inherited from IECoreMaya.UIElement
def instances
 Returns a list of all the active instances derived from the specified type. More...
 

Detailed Description

The Browser class provides a file picker interface within a Maya formLayout.

User actions cause several signals to be emitted, see the signals section. Behvaiour of the dialog can be modified by a variety of creation arguments:

Parameters
uiParentThe name of a maya UI element to parent the browser layout
optionsA callable or class with the signature ( <FileBrowser> instance, string uiParent ) that can be used to draw additional controls in the area below the list, above the path box. uiParent is an empty columnLayout. If the object passed has a method 'update' it will be connected to the pathChangedSignal of the brower instance. If the object passed has a method 'selectionChanged' it will be connected to the selectionChangedSignal of the browser instance.
filterA callable with the signature ( string path, ( {}, ... ) items ), which is allowed to modify the items list however it sees fit. See the section below on the structure of the items list. The result of the filter will be used as the item list for display.
validateA callable with the signature ( string path, ( {}, ... ) items ), which must return True of False as to wether the items in the supplied list are considered a valid 'selection'.
showHidden(bool) Wether or not hidden files should be shown in the browser.
buttonTitle(string) The label for the main button
withCancel(bool) Wether or not a cancel button should be drawn
cancelButtonTitle(string) The label for the cancel button.
rightHanded(bool) The main button defaults to the left, to match Maya's look. If you prefer the other side, to match other environments, this can be set to True.
allowMultiSelection(bool) Can the user select more than one item at once.
saveMode(bool) When enabled, the user is allowed to choose paths to files that don't exist yet. Otherwise, the selection is always conformed to an item in the list, or the current directory itself if nothing is selected.

The item list syntax:

( { "name" : (string) the name of the item as it will be displayed in the list, "path" : (string) the full path to the item, that will be returned when querying the users selection "mode" : as per os.stat() "uid" : as per os.stat() "gid" : as per os.stat() "size" : (bytes) as per os.stat() "atime" : (seconds) as per os.stat() "mtime" : (seconds) as per os.stat() "ctime" : (seconds) as per os.stat() }, ... )

NOTE: Neither 'path', nor 'name' must be valid filesystem entries. They can be modified to substitute variables or similar into the paths or item names. Validation and filtering functions are called with the 'real' working path of the browser, as well as the item list. It is up to these functions to valiate the 'correctness' of the result of the users selection. If a filter is modifying the items list, it is it's responsibility to ensure that the the relevant metadata is created for any 'synthesized' items. For example, when collapsing a file sequence into a single item, appropriate dates should be generated to permit 'by date' sorting.

Member Function Documentation

def IECoreMaya.FileBrowser.cancelSignal (   self)

This will be emitted if the user clicks the Cancel button.

Connected callables will receive the following args:

  • browserInstance <IECore.FileDialog.Browser>

References IECoreMaya.FileBrowser.__s_cancel.

def IECoreMaya.FileBrowser.getButtonTitle (   self,
  title 
)
Returns
the title of the main button.

References IECoreMaya.FileBrowser.__selectButton.

def IECoreMaya.FileBrowser.getCancelButtonTitle (   self,
  title 
)
Returns
the title of the cancel button, else None if none exists.

References IECoreMaya.FileBrowser.__cancelButton, IECoreMaya.FileBrowser.FileExtensionFilter.__check(), and IECoreMaya.FileBrowser.FileExtensionFilter.__exts.

def IECoreMaya.FileBrowser.getCurrentSelection (   self)

This function should be used to query the users selection in clases using an instance of the FileDialog.

Returns
<tuple> This returns a list of the items selected in the file browser. Each item is specified by its full path. If items names have been modified by filtering, the full path is returned with the filtered name instead of the file name. If validation is setup, and fails, () is returned.

References IECoreMaya.FileBrowser.__emitSelect(), IECoreMaya.FileBrowser.__filter, IECoreMaya.FileBrowser.__getItemInfo(), IECoreMaya.FileBrowser.__getSelectedItems(), IECoreMaya.FileBrowser.__path, IECoreMaya.FileBrowser.__saveMode, IECoreMaya.FileBrowser.__selectButton, IECoreMaya.FileBrowser.__showHidden, IECoreMaya.FileBrowser.__validate, IECoreNuke::DisplayIop._validate(), IECoreNuke::Warp._validate(), IECoreNuke::SceneCacheReader._validate(), IECoreNuke::ParameterisedHolder< BaseType >._validate(), IECoreNuke::LensDistort._validate(), IECoreMaya.FileBrowser._validate(), and IECoreMaya.FileBrowser.setPath().

def IECoreMaya.FileBrowser.pathChangedSignal (   self)

This will be emitted whenever the current directory has changed as a result of the user browsing around the file system.

Connected callables will be called with the following args:

  • path <string>

References IECoreMaya.FileBrowser.__getSelectedItems(), IECoreMaya.FileBrowser.__path, IECoreMaya.FileBrowser.__s_cancel, IECoreMaya.FileBrowser.__s_pathChanged, IECoreMaya.FileBrowser.__s_select, IECoreNuke::DisplayIop._validate(), IECoreNuke::Warp._validate(), IECoreNuke::SceneCacheReader._validate(), IECoreNuke::ParameterisedHolder< BaseType >._validate(), IECoreNuke::LensDistort._validate(), and IECoreMaya.FileBrowser._validate().

def IECoreMaya.FileBrowser.selectSignal (   self)

This will be called when the user has selected one or more items.

By either:

  • Making a selection in the file list, and clicking the main button.
  • Double clicking on a file (directories cause navigation). Connected callables will receive the following args:
  • browserInstance <IECore.FileDialog.Browser> If validation has been setup, and the current selection fails validation, the signal will not be emitted.

References IECoreMaya.FileBrowser.__s_select.

def IECoreMaya.FileBrowser.setPath (   self,
  path = None,
  allowImmediateSelection = False 
)

Sets the working path for the file browser.

Parameters
path<string> If this is the path to a file, then the dialog will display the parent directory and select the file. The pathChangedSignal is then emitted with the path to the directory. If None is passed, the listing of the current path will be refreshed.
allowImmediateSelection.When enabled, this allows a valid file name to be set as the path, and immediately validated and used. It's off by default to allow the dialogue opener to use the setPath method to set default name without thinking about it too much.

References IECoreMaya.FileBrowser.__emitPathChanged(), IECoreMaya.FileBrowser.__itemChosen(), IECoreMaya.FileBrowser.__path, IECoreMaya.FileBrowser.__saveMode, IECoreMaya.FileBrowser.__selectionChanged(), IECoreNuke::DisplayIop._validate(), IECoreNuke::Warp._validate(), IECoreNuke::SceneCacheReader._validate(), IECoreNuke::ParameterisedHolder< BaseType >._validate(), IECoreNuke::LensDistort._validate(), and IECoreMaya.FileBrowser._validate().

Referenced by IECoreMaya.FileBrowser.getCurrentSelection(), and IECoreMaya.FileDialog.removePreset().


The documentation for this class was generated from the following file: