pyworkflow.gui.form module

This modules implements the automatic creation of protocol form GUI from its params definition.

class pyworkflow.gui.form.Binding(paramName, var, protocol, *callbacks)[source]

Bases: object

class pyworkflow.gui.form.BoolVar(value=None)[source]

Bases: object

Wrapper around tk.IntVar

get()[source]
set(value)[source]
class pyworkflow.gui.form.ComboVar(enum)[source]

Bases: object

Create a variable that display strings (for combobox) but the values are integers (for the underlying EnumParam).

get()[source]
set(value)[source]
class pyworkflow.gui.form.FormWindow(title, protocol, callback, master=None, hostList=['localhost'], **kwargs)[source]

Bases: pyworkflow.gui.gui.Window

This class will create the Protocol params GUI to fill in the parameters. The creation of input parameters will be based on the Protocol Form definition. This class will serve as a connection between the GUI variables (tk vars) and the Protocol variables.

Layout:
There are 4 main blocks that goes each one in a different row1. 1. Header: will contains the logo, title and some link buttons. 2. Common: common execution parameters of each run. 3. Params: the expert level and tabs with the Protocol parameters. 4. Buttons: buttons at bottom for close, save and execute.
adjustSize()[source]
execute(e=None)[source]
getVarValue(varName)[source]

This method should retrieve a value from

getWidgetValue(protVar, param)[source]
resize(frame)[source]
save(e=None)[source]
schedule()[source]
setParamFromVar(paramName)[source]
setVar(paramName, value)[source]
setVarFromParam(paramName)[source]
updateLabelAndCommentVars()[source]

Read the label and comment first line to update the entry boxes in the form.

updateProtocolLabel()[source]
updateProtocolParams()[source]

This method is only used from WEB, since in Tk all params are updated when they are changed.

class pyworkflow.gui.form.GroupWidget(row, paramName, param, window, parent)[source]

Bases: pyworkflow.gui.form.ParamWidget

hide()[source]
show()[source]

Grid the label and content in the specified row

class pyworkflow.gui.form.LineWidget(row, paramName, param, window, parent, value, callback=None, visualizeCallback=None, column=0, showButtons=True)[source]

Bases: pyworkflow.gui.form.ParamWidget

show()[source]

Grid the label and content in the specified row

class pyworkflow.gui.form.MultiPointerTreeProvider(mapper)[source]

Bases: pyworkflow.gui.tree.TreeProvider

Store several pointers to objects to be used in a BoundTree and as storage from MultiPointerVar.

addObject(obj)[source]
getColumns()[source]

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

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

removeObject(obj)[source]
class pyworkflow.gui.form.MultiPointerVar(provider, tree)[source]

Bases: object

Wrapper around tk.StringVar to hold object pointers. This class is related with MultiPointerTreeProvider, which stores the list of pointed objects and have the logic to add and remove from the list.

get()[source]
getSelectedObjects()[source]
remove()[source]

Remove first element selected.

set(value)[source]
class pyworkflow.gui.form.ParamWidget(row, paramName, param, window, parent, value, callback=None, visualizeCallback=None, column=0, showButtons=True)[source]

Bases: object

For each one in the Protocol parameters, there will be one of this in the Form GUI. It is mainly composed by: A Label: put in the left column A Frame(content): in the middle column and container

of the specific components for this parameter

A Frame(buttons): a container for available actions buttons It will also have a Variable that should be set when creating

the specific components
static createBoolWidget(parent, **args)[source]

Return a BoolVar associated with a yes/no selection. **args: extra arguments passed to tk.Radiobutton and tk.Frame

constructors.
display(condition)[source]

show or hide depending on the condition.

get()[source]
hide()[source]
set(value)[source]
show()[source]

Grid the label and content in the specified row

class pyworkflow.gui.form.PointerVar(protocol)[source]

Bases: object

Wrapper around tk.StringVar to hold object pointers.

get()[source]
getPointer()[source]
remove()[source]
set(value)[source]
class pyworkflow.gui.form.ProtocolClassTreeProvider(protocolClassName)[source]

Bases: pyworkflow.gui.tree.TreeProvider

Will implement the methods to provide the object info of subclasses objects(of className) found by mapper

getColumns()[source]

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

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

class pyworkflow.gui.form.QueueDialog(window, queueDict)[source]

Bases: pyworkflow.gui.dialog.Dialog

Dialog to entry the queue parameters.

apply()[source]

process the data This method is called automatically to process the data, after the dialog is destroyed. By default, it does nothing.

body(bodyFrame)[source]

create dialog body. return widget that should have initial focus. This method should be overridden, and is called by the __init__ method.

validate()[source]

validate the data This method is called automatically to validate the data before the dialog is destroyed. By default, it always validates OK.

class pyworkflow.gui.form.RelationsTreeProvider(protocol, relationParam, selected=None)[source]

Bases: pyworkflow.gui.form.SubclassesTreeProvider

Will implement the methods to provide the object info of subclasses objects(of className) found by mapper

getObjects()[source]

Return the objects that will be inserted in the Tree

class pyworkflow.gui.form.ScalarTreeProvider(protocol, scalarParam, selected=None)[source]

Bases: pyworkflow.gui.tree.TreeProvider

Will implement the methods to provide the object info of scalar outputs

CREATION_COLUMN = 'Creation'
INFO_COLUMN = 'Info'
getColumns()[source]

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

getObjectInfo(pobj)[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

isSelected(obj)[source]

Check if an object is selected or not.

objectKey(pobj)[source]
class pyworkflow.gui.form.ScalarWithPointerVar(protocol, changeListener)[source]

Bases: tkinter.StringVar

tk.StringVar to hold object pointers and scalars.

get()[source]

Return value of variable as string.

getPointer()[source]
hasPointer()[source]
set(value)[source]

Set the variable to VALUE.

trace(mode, callback)[source]

Define a trace callback for the variable.

MODE is one of “r”, “w”, “u” for read, write, undefine. CALLBACK must be a function which is called when the variable is read, written or undefined.

Return the name of the callback.

This deprecated method wraps a deprecated Tcl method that will likely be removed in the future. Use trace_add() instead.

class pyworkflow.gui.form.SectionFrame(master, label, callback=None, height=15, **args)[source]

Bases: tkinter.Frame

This class will be used to create a frame for the Section That will have a header with red color and a content frame with white background

adjustContent()[source]
class pyworkflow.gui.form.SectionWidget(form, master, section, height, callback=None, **args)[source]

Bases: pyworkflow.gui.form.SectionFrame

This class will be used to create a section in FormWindow

get()[source]

Return boolean value if is selected

hide()[source]
set(value)[source]
show()[source]
class pyworkflow.gui.form.SubclassesTreeProvider(protocol, pointerParam, selected=None)[source]

Bases: pyworkflow.gui.tree.TreeProvider

Will implement the methods to provide the object info of subclasses objects(of className) found by mapper

CREATION_COLUMN = 'Creation'
ID_COLUMN = 'Protocol Id'
INFO_COLUMN = 'Info'
getColumns()[source]

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

getObjectActions(pobj)[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(pobj)[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

isSelected(obj)[source]

Check if an object is selected or not.

objectKey(pobj)[source]
class pyworkflow.gui.form.TextVar(text, value='')[source]

Bases: object

Wrapper around tk.StringVar to bind the value of a Text widget.

get()[source]
set(value)[source]
class pyworkflow.gui.form.VerticalScrolledFrame(parent, *args, **kw)[source]

Bases: tkinter.Frame

A pure Tkinter scrollable frame that actually works! * Use the ‘interior’ attribute to place widgets inside the scrollable frame * Construct and pack/place/grid normally * This frame only allows vertical scrolling

pyworkflow.gui.form.editObject(self, title, root, obj, mapper)[source]

Show a Text area to edit the protocol label and comment.

pyworkflow.gui.form.getObjectLabel(pobj, mapper)[source]

We will try to show in the list the string representation that is more readable for the user to pick the desired object.

pyworkflow.gui.form.getPointerLabelAndInfo(pobj, mapper)[source]

Return a string to represent selected objects that are stored by pointers. This function will be used from PointerVar and MultiPointerVar.