pyworkflow.gui.browser module

In this module a simple ObjectBrowser is implemented. This class can be subclasses to extend its functionality. A concrete use of ObjectBrowser is FileBrowser, where the elements to inspect and preview are files.

class pyworkflow.gui.browser.BrowserWindow(title, master=None, **kwargs)[source]

Bases: pyworkflow.gui.gui.Window

Windows to hold a browser frame inside.

setBrowser(browser, row=0, column=0)[source]
class pyworkflow.gui.browser.ChimeraHandler[source]

Bases: pyworkflow.gui.browser.FileHandler

getFileActions(objFile)[source]

Return actions that can be done with this object. Actions will be displayed in the context menu and the first one will be the default when double-click.

getFileIcon(objFile)[source]

Return the icon name for a given file.

class pyworkflow.gui.browser.FileBrowser(parent, initialDir='.', selectionType=1, selectionSingle=True, allowFilter=True, filterFunction=None, previewDim=144, showHidden=False, selectButton='Select', entryLabel=None, entryValue='', showInfo=None, shortCuts=None, onlyFolders=False)[source]

Bases: pyworkflow.gui.browser.ObjectBrowser

The FileBrowser is a particular class of ObjectBrowser where the “objects” are just files and directories.

getCurrentDir()[source]
getEntryValue()[source]
onClose()[source]
onSelect(obj)[source]
class pyworkflow.gui.browser.FileBrowserWindow(title, master=None, path=None, onSelect=None, shortCuts=None, **kwargs)[source]

Bases: pyworkflow.gui.browser.BrowserWindow

Windows to hold a file browser frame inside.

getCurrentDir()[source]
getEntryValue()[source]
registerHandlers()[source]
class pyworkflow.gui.browser.FileHandler[source]

Bases: object

This class will be used to get the icon, preview and info from the different types of objects. It should be used with FileTreeProvider, where different types of handlers can be registered.

getFileActions(objFile)[source]

Return actions that can be done with this object. Actions will be displayed in the context menu and the first one will be the default when double-click.

getFileIcon(objFile)[source]

Return the icon name for a given file.

getFilePreview(objFile)[source]

Return the preview image and description for the specific object.

class pyworkflow.gui.browser.FileInfo(path, filename)[source]

Bases: object

This class will store some information about a file. It will serve to display files items in the Tree.

getDate()[source]
getDateStr()[source]
getFileName()[source]
getPath()[source]
getSize()[source]
getSizeStr()[source]

Return a human readable string of the file size.

isDir()[source]
class pyworkflow.gui.browser.FileTreeProvider(currentDir=None, showHidden=False, onlyFolders=False)[source]

Bases: pyworkflow.gui.tree.TreeProvider

Populate a tree with files and folders of a given path

FILE_COLUMN = 'File'
SIZE_COLUMN = 'Size'
fileKey(f)[source]
getDir()[source]
getFileHandler(obj)[source]
getObjectActions(obj)[source]
getObjectInfo(obj)[source]
getObjectPreview(obj)[source]
getObjects()[source]
classmethod registerFileHandler(fileHandler, *extensions)[source]

Register a FileHandler for a given file extension. Params:

fileHandler: the FileHandler that will take care of extensions. *extensions: the extensions list that will be associated to this

FileHandler.
setDir(newPath)[source]
class pyworkflow.gui.browser.ImageFileHandler[source]

Bases: pyworkflow.gui.browser.FileHandler

getFileActions(objFile)[source]

Return actions that can be done with this object. Actions will be displayed in the context menu and the first one will be the default when double-click.

getFilePreview(objFile)[source]

Return the preview image and description for the specific object.

class pyworkflow.gui.browser.MdFileHandler[source]

Bases: pyworkflow.gui.browser.ImageFileHandler

getFileIcon(objFile)[source]

Return the icon name for a given file.

getFilePreview(objFile)[source]

Return the preview image and description for the specific object.

class pyworkflow.gui.browser.ObjectBrowser(parent, treeProvider, showPreview=True, showPreviewTop=True, **args)[source]

Bases: Tkinter.Frame

This class will implement a simple object browser. Basically, it will display a list of elements at the left panel and can display a preview and description on the right panel for the selected element. An ObjectView will be used to grab information for each element such as: icon, preview and description. A TreeProvider will be used to populate the list (Tree).

getSelected()[source]

Return the selected object.

class pyworkflow.gui.browser.ParticleFileHandler[source]

Bases: pyworkflow.gui.browser.ImageFileHandler

getFileIcon(objFile)[source]

Return the icon name for a given file.

class pyworkflow.gui.browser.ShortCut(path, name, icon=None, toolTip='')[source]

Shortcuts to paths to be displayed in the file browser

static factory(path, name, icon=None, toolTip='')[source]

Factory method to create shortcuts

class pyworkflow.gui.browser.SqlFileHandler[source]

Bases: pyworkflow.gui.browser.FileHandler

getFileIcon(objFile)[source]

Return the icon name for a given file.

class pyworkflow.gui.browser.StackHandler[source]

Bases: pyworkflow.gui.browser.ImageFileHandler

getFileIcon(objFile)[source]

Return the icon name for a given file.

class pyworkflow.gui.browser.TextFileHandler(textIcon)[source]

Bases: pyworkflow.gui.browser.FileHandler

getFileIcon(objFile)[source]

Return the icon name for a given file.

class pyworkflow.gui.browser.VolFileHandler[source]

Bases: pyworkflow.gui.browser.ImageFileHandler

getFileIcon(objFile)[source]

Return the icon name for a given file.

pyworkflow.gui.browser.isStandardImage(filename)[source]

Check if a filename have an standard image extension.