pyworkflow.gui.dialog module

Module to handling Dialogs some code was taken from tkSimpleDialog

class pyworkflow.gui.dialog.Dialog(parent, title, lockGui=True, **kwargs)[source]

Bases: Toplevel

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

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

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

buttonbox(btnFrame)[source]
cancel(event=None)[source]
destroy()[source]

Destroy the window

getImage(imgName)[source]

A shortcut to get an image from its name

getResult()[source]
info(message)[source]

Shows a info message for long running processes to inform the user GUI is not frozen

resultCancel()[source]
resultNo()[source]
resultYes()[source]
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.

validateClose()[source]
class pyworkflow.gui.dialog.EditObjectDialog(parent, title, obj, mapper, **kwargs)[source]

Bases: Dialog

Dialog to edit some text

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

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.

buttonbox(btnFrame)[source]
getComment()[source]
getLabel()[source]
class pyworkflow.gui.dialog.EntryDialog(parent, title, entryLabel, entryWidth=20, defaultValue='', headerLabel=None)[source]

Bases: Dialog

Dialog to ask some entry

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

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.dialog.ExceptionDialog(*args, **kwargs)[source]

Bases: MessageDialog

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

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.

class pyworkflow.gui.dialog.FileBrowseDialog(parent, title, provider, message=None, **args)[source]

Bases: Dialog

Dialog to select files from the filesystem.

From args: message: message tooltip to show when browsing. selected: the item that should be selected.

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.dialog.FlashMessage(master, msg, delay=5, relief='solid', func=None)[source]

Bases: object

close()[source]
process(func)[source]
class pyworkflow.gui.dialog.FloatingMessage(master, msg, xPos=None, yPos=None, textWidth=280, font='Helvetica', size=12, bd=1, bg='Firebrick', fg='white')[source]

Bases: object

close()[source]
setMessage(msg)[source]
show()[source]
class pyworkflow.gui.dialog.GenericDialog(master, title, msg, iconPath, **kwargs)[source]

Bases: Dialog

Create a dialog with many buttons Arguments:

parent – a parent window (the application window) title – the dialog title msg – message to display into the dialog iconPath – path of the image to show into the dialog

**args accepts:

buttons – list of buttons tuples containing which buttons to display and theirs values icons – list of icons for all buttons default – button default

Example:
buttons=[(‘Single’, RESULT_RUN_SINGLE),

(‘All’, RESULT_RUN_ALL), (‘Cancel’, RESULT_CANCEL)],

default=’Cancel’, icons={RESULT_CANCEL: Icon.BUTTON_CANCEL,

RESULT_RUN_SINGLE: Icon.BUTTON_SELECT, RESULT_RUN_ALL: Icon.ACTION_EXECUTE})

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

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.

class pyworkflow.gui.dialog.ListDialog(parent, title, provider, message=None, **kwargs)[source]

Bases: Dialog

Dialog to select an element from a list. It is implemented using the Tree widget.

From kwargs:

Parameters
  • message – message tooltip to show when browsing.

  • validateSelectionCallback – a callback function to validate selected items.

  • previewCallback – method to be called on item click to fill the callback frame.

  • selectmode – ‘extended’ by default. Selection mode of the tk.Tree

  • selectOnDoubleClick – (False). If True, double click will trigger “Select” button click

  • allowsEmptySelection – (False). Allows empty selection

  • allowSelect – if set to False, the ‘Select’ button will not be shown.

  • allowsEmptySelection – if set to True, it will not validate that at least one element was selected.

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.dialog.MessageDialog(parent, title, msg, iconPath, **args)[source]

Bases: Dialog

Dialog subclasses to show message info, questions or errors. It can display an icon with the message

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

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.

class pyworkflow.gui.dialog.SearchBaseWindow(parentWindow, title='Search element', onClick=None, onDoubleClick=None, **kwargs)[source]

Bases: Window

Base window for searching in a list You are going to implement several elements:

columnsConfig: a dictionary with elements with this structure:

<column-key>: (<title>,{kwargs for tree.column method}, weight, <casting_method>(optional, otherwise str))

Example:

columnConfig = {

‘#0’: (‘Status’, {‘width’: 50, ‘minwidth’: 50, ‘stretch’: tk.NO}, 3), ‘protocol’: (‘Protocol’, {‘width’: 300, ‘stretch’: tk.FALSE}), 5, ‘streaming’: (‘Streamified’, {‘width’: 100, ‘stretch’: tk.FALSE}, 3), ‘installed’: (‘Installation’, {‘width’: 110, ‘stretch’: tk.FALSE}, 3), ‘help’: (‘Help’, {‘minwidth’: 300, ‘stretch’: tk.YES}, 3), ‘score’: (‘Score’, {‘width’: 50, ‘stretch’: tk.FALSE}, 3, int),

}

_createResultsTree method _onSearchClick method

See SearchProtocolWindow as an example

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

CASTING_INDEX = 3
COLUMN_KWARGS_INDEX = 1
COLUMN_TEXT_INDEX = 0
WEIGHT_INDEX = 2
addSearchWeight(line2Search, searchtext)[source]
columnConfig = {}
getColumnKeys()[source]
class pyworkflow.gui.dialog.ToolbarButton(text, command, icon=None, tooltip=None, shortcut=None)[source]

Bases: object

Store information about the buttons that will be added to the toolbar.

class pyworkflow.gui.dialog.ToolbarListDialog(parent, title, provider, message=None, toolbarButtons=None, **kwargs)[source]

Bases: ListDialog

This class extend from ListDialog to allow an extra toolbar to handle operations over the elements in the list (e.g. Edit, New, Delete).

From kwargs: message: message tooltip to show when browsing. selected: the item that should be selected. validateSelectionCallback:

a callback function to validate selected items.

allowSelect: if set to False, the ‘Select’ button will not

be shown.

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.

class pyworkflow.gui.dialog.YesNoDialog(master, title, msg, **kwargs)[source]

Bases: MessageDialog

Ask a question with YES/NO answer

Initialize a dialog. Arguments:

parent – a parent window (the application window) title – the dialog title

**args accepts:

buttons – list of buttons tuples containing which buttons to display

pyworkflow.gui.dialog.askColor(parent, defaultColor='black')[source]
pyworkflow.gui.dialog.askSingleAllCancel(title, msg, parent)[source]
pyworkflow.gui.dialog.askString(title, label, parent, entryWidth=20, defaultValue='', headerLabel=None)[source]
pyworkflow.gui.dialog.askYesNo(title, msg, parent)[source]
pyworkflow.gui.dialog.askYesNoCancel(title, msg, parent)[source]
pyworkflow.gui.dialog.createMessageBody(bodyFrame, message, image, frameBg='white', textBg='white', textPad=5)[source]

Create a Text containing the message. Params:

bodyFrame: tk.Frame to be filled. msg: a str or list with the lines.

pyworkflow.gui.dialog.fillMessageText(text, message)[source]
pyworkflow.gui.dialog.showError(title, msg, parent, exception=None)[source]
pyworkflow.gui.dialog.showInfo(title, msg, parent)[source]
pyworkflow.gui.dialog.showWarning(title, msg, parent)[source]