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:
Window
Windows to hold a browser frame inside.
Create a Tk window. title: string to use as title for the windows. master: if not provided, the windows create will be the principal one weight: if true, the first col and row will be configured with weight=1 minsize: a minimum size for height and width icon: if not None, set the windows icon
- 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:
ObjectBrowser
The FileBrowser is a particular class of ObjectBrowser (Tk.Frame) where the “objects” are just files and directories.
- Parameters
parent – Parent tkinter window.
initialDir – Folder to show when loading the dialog.
selectionType – Any of SELECT_NONE, SELECT_FILE, SELECT_FOLDER, SELECT_PATH.
showHidden – Pass True to show hidden files.
selectButton – text for the select button. Defaults to Select.
entryLabel – text for the entry widget. Default None. There will be no entry.
entryValue – default value for the entry. Needs entryLabel.
showInfo – callback to show a string message, otherwise _showInfo will be used.
shortCuts – list of extra
ShortCut
onlyFolders – Pass True to show only folders.
- class pyworkflow.gui.browser.FileBrowserWindow(title, master=None, path=None, onSelect=None, shortCuts=None, **kwargs)[source]
Bases:
BrowserWindow
Windows to hold a file browser frame inside.
Create a Tk window. title: string to use as title for the windows. master: if not provided, the windows create will be the principal one weight: if true, the first col and row will be configured with weight=1 minsize: a minimum size for height and width icon: if not None, set the windows icon
- lastValue = None
- 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.
- 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.
- class pyworkflow.gui.browser.FileTreeProvider(currentDir=None, showHidden=False, onlyFolders=False)[source]
Bases:
TreeProvider
Populate a tree with files and folders of a given path
- FILE_COLUMN = 'File'
- SIZE_COLUMN = 'Size'
- getObjectActions(obj)[source]
Return a list of tuples (key, action) were keys are the string options that will be display in the context menu and the actions are the functions to call when the specific action is selected. The first action in the list will be taken as the default one when the element is double-clicked.
- getObjectInfo(obj)[source]
This function will be called by the Tree with each object that will be inserted. A dictionary should be returned with the possible following entries: ‘key’: the key value to insert in the Tree ‘text’: text of the object to be displayed
(if not passed the ‘key’ will be used)
‘image’: image path to be displayed as icon (optional) ‘parent’: the object’s parent in which insert this object (optional) ‘tags’: list of tags names (optional)
- getObjectPreview(obj)[source]
Should return a tuple (img, desc), where img is the preview image and desc the description string.
- class pyworkflow.gui.browser.ObjectBrowser(parent, treeProvider, showPreview=True, showPreviewTop=True, **args)[source]
Bases:
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).
Construct a frame widget with the parent MASTER.
Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.
- class pyworkflow.gui.browser.ShortCut(path, name, icon=None, toolTip='')[source]
Bases:
object
Shortcuts to paths to be displayed in the file browser
- class pyworkflow.gui.browser.SqlFileHandler[source]
Bases:
FileHandler
- class pyworkflow.gui.browser.TextFileHandler(textIcon)[source]
Bases:
FileHandler