/ . / OpenSave / miller.py / MillerBrowser
Miller-column file system browser
style can be open or save
selections are always a list, even if multiple is 0
initialdir is where the browser points to at start
initialfile is the file/directory name that will initially
appear in the type-in widget.
dirsOnly controls whether the browser shows files or not.
filters is a (possibly empty) list of tuples: (type
description, glob(s)) [for open panels] or (type description,
glob(s), extension) [for save panels]. The type description
is used in the interface to describe the filtering (should be
something like "PDB") and is returned when the type method is
called. glob(s) can be either a single glob string or a list
of such strings. The glob(s) are used to filter the files
(directories if dirOnly is true) shown in the browser.
If dirsOnly is true, globs will have / appended if they
don't already end in / . Glob matching is always case-
insensitive. By default, extension will be appended to the
save file name if no extension is specified (and therefore
typically begins with a . ). The user can override this
behavior. extension can be None. filters can be an
empty tuple if no filtering is needed.
defaultFilter controls what filter is initially on. It is
an index into the filters list. Can be one of the filter
descriptions or a menu index. Negative indices count from the
end of the menu.
addAll controls whether an all files (or directories)
choice will be added to the list of filters (only will be
added if list of filters is non-empty)
historyID is used to keep a per-dialog file history list.
It should be a string that differs between browsers that
open/save different files. For example, "main chimera file
open" or "FindHBond file save".
compressed controls whether compressed files are shown in
the browser. By default, compressed files are shown in
browsers whose style is open . Files are considered to
be compressed if they have a suffix in compressSuffixes.
kw are passed to the Tkinter.Frame constructor
Methods
|
|
|
getPathsAndTypes
|
getPathsAndTypes ( self, remember=1 )
Get the path(s) indicated in the browser, and their types.
Returns a (possibly empty) list of path/type two-tuples.
If remember is true, then the paths will be remembered
in the list of file and directory favorites. Note that
the list can't be empty if used from one of the OpenSave
classes, since those classes will not enable the Open/
Save button unless the path is valid.
Since this method may query the user for types, it should
only be called once per dialog use
|
|
makeFaveFiles
|
makeFaveFiles ( self )
|
|
__init__
|
__init__ (
self,
parent=None,
style='open',
multiple=0,
initialdir=None,
initialfile=None,
dirsOnly=0,
filters=[],
defaultFilter=None,
addAll=1,
readyCommand=None,
dblClickCommand=None,
setFilterCommand=None,
fileEntryCommand=None,
historyID="",
compressed=None,
**kw,
)
|
|
rememberFile
|
rememberFile ( self, fileName )
Put a file in the list of file favorites
|
|
makeFaveDirs
|
makeFaveDirs ( self )
|
|
columnChange
|
columnChange ( self, event )
|
|
setPath
|
setPath ( self, path )
Set the path shown in the browser
One normally use the initialdir keyword to __init__ to
set up the initial browser path. setPath is used if
the path must be changed programatically after that.
|
|
getPaths
|
getPaths ( self, remember=1 )
Get the path(s) indicated in the browser.
Returns a (possibly empty) list of paths. If remember
is true, then the paths will be remembered in the list
of file and directory favorites.
|
|
getFilter
|
getFilter ( self )
Get the type description associated with the current filter.
|
|
pathExists
|
pathExists ( self, path )
Due to the vagaries of Windows network shares,
must use this instead of os.path.exists
|
|
newFolder
|
newFolder ( self )
|
|
rememberDir
|
rememberDir ( self, dirName )
Put a directory in the list of directory favorites
|
|
setFilter
|
setFilter (
self,
descript,
filt=None,
)
Set the file filtering in the browser.
The defaultFilter keyword of __init__ is normally
used to set up initial filtering, so this is only used
if the filtering must be changed programatically after
that.
descript is the type description associated with
the filter. filt is for internal use only.
Exceptions
|
|
KeyError, "No filter named '%s'" %( descript )
|
|
|
allowingCompressed
|
allowingCompressed ( self )
|
|
addFilter
|
addFilter (
self,
filterInfo,
index=-1,
)
Add the given filter to the list of filters.
filterInfo is the same format as a single entry of
the filters keyword of __init__. index is where
in the list of filter to insert the new filter.
|
|
newFolderCB
|
newFolderCB ( self, button )
|
|
makeFilterMenu
|
makeFilterMenu ( self )
|
|
makeMainColumn
|
makeMainColumn (
self,
path,
errorPath=None,
firstTime=False,
)
|
|
|