pyworkflow.gui.tree module

class pyworkflow.gui.tree.AttributesTreeProvider(item)[source]

Bases: ListTreeProviderString

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)

getText(obj)[source]

Get the text to display for an object.

getValues(obj)[source]
class pyworkflow.gui.tree.BoundTree(master, provider, frame=True, **opts)[source]

Bases: Tree

This class is base on Tree but fetch the items from a TreeProvider, which provides columns values for each item and items info to insert into the Tree

Create a new Tree, if frame=True, a container frame will be created and a scrollbar will be added

getColumnKeyByColumnName(columnName)[source]
getObjectFromId(treeId)[source]

Return the corresponding object from a given Tree item id.

getSelectedObjects()[source]
itemConfig(obj, **args)[source]

Configure inserted items.

iterSelectedObjects()[source]
setProvider(provider)[source]

Set new provider and updated items.

sortTree(heading, column)[source]
update()[source]

Enter event loop until all pending events have been processed by Tcl.

class pyworkflow.gui.tree.DbTreeProvider(dbName, classesDict)[source]

Bases: ObjectTreeProvider

Retrieve the elements from the database

class pyworkflow.gui.tree.ListTreeProvider(objList=None)[source]

Bases: TreeProvider

Simple list tree provider.

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)

getObjs()[source]

Get the objects.

getText(obj)[source]

Get the text to display for an object.

class pyworkflow.gui.tree.ListTreeProviderString(objList=None)[source]

Bases: ListTreeProvider

getText(obj)[source]

Get the text to display for an object.

class pyworkflow.gui.tree.ListTreeProviderTemplate(objList=None)[source]

Bases: ListTreeProviderString

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)

getText(obj)[source]

Get the text to display for an object.

getValues(obj)[source]
class pyworkflow.gui.tree.ObjectTreeProvider(objList=None)[source]

Bases: TreeProvider

Populate Tree from Objects.

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.

getObjects()[source]

Return the objects that will be inserted in the Tree

class pyworkflow.gui.tree.ProjectRunsTreeProvider(project, **kwargs)[source]

Bases: TreeProvider

Provide run list from a project to populate a tree.

ID_COLUMN = 'Id'
RUN_COLUMN = 'Run'
STATE_COLUMN = 'State'
TIME_COLUMN = 'Time'
getColumns()[source]

Return a list of tuples (c, w) where: c: is the column name and index w: is the column width

getObjectFromId(objId)[source]
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)

getObjects()[source]

Return the objects that will be inserted in the Tree

runsKey(run)[source]
setRefresh(value)[source]
class pyworkflow.gui.tree.Tree(master, frame=True, **opts)[source]

Bases: Treeview, Scrollable

This widget acts as a wrapper around the ttk.Treeview

Create a new Tree, if frame=True, a container frame will be created and an scrollbar will be added

clear()[source]

remove all items

getFirst()[source]

Return first selected item or None if selection empty

getImage(img)[source]
moveItemDown(e=None)[source]

if selected item is not the first move up one position

moveItemUp(e=None)[source]

if selected item is not the first move up one position

moveSelectionDown(e=None)[source]

change selection to to next item

moveSelectionUp(e=None)[source]

change selection to previous item

search(initial, fromSelected=True)[source]

Search the first item starting with “start” Implemented for Flat tree like FileBrowser…TODO: consider a proper tree with branches and leaves..

Parameters
  • initial (String - text to look for in the items. Usually the first initial letter)

  • fromSelected (Boolean, start looking from the selected item)

selectChild(child)[source]
selectChildByIndex(index)[source]

Select the item at the position index

sortByColumn(col, reverse, casting=<class 'str'>)[source]

Function to sort a treeview :param self: treview :param col: column to apply the sorting on :param reverse: sorting direction :param casting: optional - casting operation to apply on the column value: str is default. int, float are other options :return:

class pyworkflow.gui.tree.TreeProvider(sortingColumnName=None, sortingAscending=True)[source]

Bases: object

Class class will serve to separate the logic of feed data from the graphical Tree build. Subclasses should implement the abstract methods

configureTags(tree)[source]

Configure the available tags in the tree that will be setup later for each item in the tree. :returns: * Nothing

  • Adds tags to the tree for customizing

getColumns()[source]

Return a list of tuples (c, w) where: c: is the column name and index w: is the column width

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.

getObjects()[source]

Return the objects that will be inserted in the Tree

getSortingColumnName()[source]
isSortingAscending()[source]
setSortingParams(columnName, ascending)[source]

Column name to sort by it and sorting direction :Parameters: * columnName (Name of the column)

  • ascending (If true sorting will be ascending.)

Return type

Nothing

sortEnabled()[source]