Package schrodinger :: Package ui :: Package qt :: Module appframework :: Class JobInputFrame
[hide private]
[frames] | no frames]

Class JobInputFrame

       object --+                    
                |                    
sip.simplewrapper --+                
                    |                
          sip.wrapper --+            
                        |            
     PyQt4.QtCore.QObject --+        
                            |        
           object --+       |        
                    |       |        
    sip.simplewrapper --+   |        
                        |   |        
 PyQt4.QtGui.QPaintDevice --+        
                            |        
          PyQt4.QtGui.QWidget --+    
                                |    
               PyQt4.QtGui.QFrame --+
                                    |
                                   JobInputFrame


An application input source selection widget.

Allows the user to choose the source of the job input:  Project Table,
files, or Workspace (which is not included entries, just the Workspace
ct).

Configuration options set via constructor keywords are...

    filetypes -    If file input allowed, the file filters used in the
                   askopenfilename.  List of tuples.  Default is
                   [('Maestro Files', '*.mae')].
    initialdir -   If file input allowed, the default initial directory
                   in the askopenfilename.  Default is '.'.
    file -         Allow an external file as an input source.  Default is
                   True.
    selected_entries - Allow the selected Project Table entries to be used
                   as an input source.  Maestro only.  Default is True.
    included_entries - Allow the included Project Table entries to be used
                   as an input source. Maestro only. Default is False.
    included_entry - Allow the single included Project Table entry to be
                   used as an input source. An error is presented if more
                   than one entry is included. Properties are preserved.
                   Maestro only. Default is False.
    workspace -    Allow the Workspace structure as an input source. If
                   more than one entry is included, they are merged and
                   CT-level properties are dropped.
                   Maestro only. Default is True. Consider using the
                   'included_entries' or 'included_entry' instead.

    default_source - What the default source should be. Must be one of:
                     "file", "selected_entries", "included_entries",
                     "included_entry", or "workspace".
                     Default is "selected_entries", if enabled; if not,
                     then "file" (if enabled)

    writefile -    Automatically generate the '<jobname>.<ext>' file from
                   WS/PT/FILE source. Default is True.
                   If True:
                     The written file name is stored as 'inputstrucfile'
                     in the JobParameters object. For FILE source, original
                     file path is also stored as 'inputstrucorigfile'.
                   If False:
                     For FILE source, store file path to "inputstrucfile"
                     For WORKSPACE and INCLUDED_ENTRY sources, store
                     structure to "inputstruc". For SELECTED_ENTRIES and
                     INCLUDED_ENTRIES sources, nothing is stored.
                     It is user's job then use this information as desired.
    label_text -   Default is: 'Use structures from:'

    file_text -    Default is: "File name:" / "File names:"

    tracking -     Track whether structures selected for input have changed.
                   Type of changes tracked:
                        User changes input type (File/Workspace/Etc.)
                        User selects a new file (via Browse or typing)
                        PT inclusion/selection changes when those are the
                        selected input
                        Workspace changes when Workspace is the selected
                        input
                    When one of these changes occur, the JobInputFrame
                    object emits an input_changed signal.

                    Workspace changes are only tracked if the selected input
                    is Workspace, unless extra_ws_tracking is set to True.

                    If selected_entries is chosen as the input source,
                    changes in the inclusion state of a selected entry will
                    emit the only_inclusion_changed signal rather than the
                    input_changed signal.

                    Tracking will only occur if the panel is currently shown

                    The default is tracking=False because this adds overhead
                    to every workspace change and project update.


    extra_ws_tracking - Track workspace changes when the selected input is
                        PT selection or WS inclusion. This will emit a input
                        _changed signal whenever one of the selected entries
                        is in the workspace and Maestro calls the
                        workspaceChanged callback with
                        WORKSPACE_CHANGED_EVERYTHING,
                        WORKSPACE_CHANGED_APPEND, or
                        WORKSPACE_CHANGED_CONNECTIVITY

                        Without setting this to True, no signal is emitted
                        if the input selected is PT selection or inclusion,
                        and the user edits one of the input structures in
                        the WS.

                        This will result in multiple input_changed signal
                        emissions for a single change in inclusion - one for
                        the project update and multiple emits because
                        Maestro calls the callback multiple times for each
                        (un)inclusion.

                        No signal will be emitted for workspace changes if
                        none of the selected entries are currently included
                        in the Workspace.

                        The default is extra_ws_tracking=False due to the
                        extra overhead of this signal.

Job parameters passed out in the getParams() JobInputParams object are...

    state -         The input source type, FILE, SELECTED_ENTRIES,
                    INCLUDED_ENTRIES, INCLUDED_ENTRY, or WORKSPACE
    fileselection - The file name if FILE source

These are not JobParameters attributes, and the input structure file is not
written by this class.  JobInputFrame does that work.

Nested Classes [hide private]

Inherited from PyQt4.QtGui.QFrame: Shadow, Shape, StyleMask

Inherited from PyQt4.QtGui.QWidget: RenderFlag, RenderFlags

Inherited from PyQt4.QtGui.QPaintDevice: PaintDeviceMetric

Instance Methods [hide private]
 
__init__(self, parent, **kwargs)
See class docstring.
 
_fileSelectSetEnabled(self, enable)
Turn the file selector browse button and entry field or or off.
Iterator of structure.Structure
_getFileStsIterator(self)
Return an iterator of structures in the user-selected file, honoring the range, is specified.
 
_reset(self)
Reset the input frame
 
addCallback(self, callback_adder, method)
Add a callback for a method - quietly do nothing if such callback already exists.
 
addFileWidgets(self)
Add widgets associated with a file input source to the input frame.
 
addRangeWidgets(self)
Add from/to range widgets under the file entry field.
 
browseFiles(self)
Callback method of the file browse button.
 
getFile(self)
Return the contents of the filename entry field.
 
getFileInputInfo(self)
Emit input_changed if the new file picked by the user is different from the old file
 
getFiles(self)
Return the list of file names from the file entry field.
 
getIncludedEntryInfo(self)
Track the included entries and emit input_changed if the set of included entries changes
 
getParams(self)
If the current GUI state isn't valid, pop up an error message and return None.
 
getSelectedEntryInfo(self)
Track the selected entries and emit input_changed if the set of selected entries changes.
 
hideEvent(self, event)
Deregister callbacks when the panel hides itself so that we are not monitoring changes when the panel is inactive.
 
inputState(self)
Return the input type as class constant FILE, SELECTED_ENTRIES, INCLUDED_ENTRIES, INCLUDED_ENTRY, or WORKSPACE.
 
input_changed(...)
 
only_inclusion_changed(...)
 
removeAllCallbacks(self)
Remove any previously added callbacks.
 
removeCallback(self, callback_adder, method)
Remove a callback that may have been registered previously - silently do nothing if the callback isn't registered.
 
setFile(self, filename)
Select the specified filename in the input selector.
 
setInputState(self, input_state)
Set the input type.
 
setup(self, jobparam)
This method serializes the input structure(s) to disk and stores the name of the file in the jobparam instance.
 
showEvent(self, event)
Make sure the proper signals are emitted and proper callbacks are registered when the panel shows itself
 
structures(self, validate=True)
A generator that returns the user-specified input structures one at a time.
 
toggleExtraWSTracking(self)
Toggles on/off rigorous tracking of WS changes for included entries depending on whether it is requested and whether any selected inputs are included in the Workspace.
 
updateInput(self, result)
Callback method of the input option menu.
int
validate(self)
Validate that the JobInputFrame is in a consistent and complete state.
 
warning(self, text)
Display a warning window with the specified text.
 
workspaceChanged(self, what_changed)
Emit input_changed if the Workspace change merits is
 
writePTEntries(self, filename, warn=False, append=False, source='Project Table (selected entries)')
Write selected Project Table entries to 'filename'.
 
writeSelectedEntries(self, filename, warn=False, append=False)
For backwards-compatability.

Inherited from PyQt4.QtGui.QFrame: changeEvent, drawFrame, event, frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, paintEvent, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth, sizeHint

Inherited from PyQt4.QtGui.QWidget: acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsMargins, contentsRect, contextMenuEvent, contextMenuPolicy, create, cursor, customContextMenuRequested, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, enabledChange, ensurePolished, enterEvent, find, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontChange, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabGesture, grabKeyboard, grabMouse, grabShortcut, graphicsEffect, graphicsProxyWidget, handle, hasFocus, hasMouseTracking, height, heightForWidth, hide, inputContext, inputMethodEvent, inputMethodHints, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isEnabledToTLW, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isTopLevel, isVisible, isVisibleTo, isWindow, isWindowModified, keyPressEvent, keyReleaseEvent, keyboardGrabber, languageChange, layout, layoutDirection, leaveEvent, locale, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, overrideWindowFlags, overrideWindowState, paintEngine, palette, paletteChange, parentWidget, pos, previousInFocusChain, raise_, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, repaint, resetInputContext, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedWidth, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGraphicsEffect, setHidden, setInputContext, setInputMethodHints, setLayout, setLayoutDirection, setLocale, setMask, setMaximumHeight, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setShortcutAutoRepeat, setShortcutEnabled, setShown, setSizeIncrement, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowTitle, show, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, topLevelWidget, underMouse, ungrabGesture, unsetCursor, unsetLayoutDirection, unsetLocale, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, winId, window, windowActivationChange, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, x, x11Info, x11PictureHandle, y

Inherited from PyQt4.QtCore.QObject: __getattr__, blockSignals, childEvent, children, connect, connectNotify, customEvent, deleteLater, destroyed, disconnect, disconnectNotify, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, emit, eventFilter, findChild, findChildren, inherits, installEventFilter, isWidgetType, killTimer, metaObject, moveToThread, objectName, parent, property, pyqtConfigure, receivers, removeEventFilter, sender, senderSignalIndex, setObjectName, setProperty, signalsBlocked, startTimer, thread, timerEvent, tr, trUtf8

Inherited from PyQt4.QtGui.QPaintDevice: colorCount, depth, heightMM, logicalDpiX, logicalDpiY, numColors, paintingActive, physicalDpiX, physicalDpiY, widthMM

Inherited from sip.simplewrapper: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  ERROR = 1
  FILE = 'File'
  FILE_STATES = set(['File', 'Files'])
  INCLUDED_ENTRIES = 'Workspace (included entries)'
  INCLUDED_ENTRY = 'Workspace (included entry)'
  INCLUDED_STATES = set(['Workspace (included entries)', 'Worksp...
  OK = 0
hash(x)
  PROJECT_TABLE = 'Project Table (selected entries)'
  SELECTED_ENTRIES = 'Project Table (selected entries)'
  WORKSPACE = 'Workspace'
  _FILES = 'Files'

Inherited from PyQt4.QtGui.QFrame: Box, HLine, NoFrame, Panel, Plain, Raised, Shadow_Mask, Shape_Mask, StyledPanel, Sunken, VLine, WinPanel

Inherited from PyQt4.QtGui.QWidget: DrawChildren, DrawWindowBackground, IgnoreMask

Inherited from PyQt4.QtCore.QObject: staticMetaObject

Inherited from PyQt4.QtGui.QPaintDevice: PdmDepth, PdmDpiX, PdmDpiY, PdmHeight, PdmHeightMM, PdmNumColors, PdmPhysicalDpiX, PdmPhysicalDpiY, PdmWidth, PdmWidthMM

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent, **kwargs)
(Constructor)

 

See class docstring. Raises an Exception if no input source is allowed.

Overrides: object.__init__

_getFileStsIterator(self)

 

Return an iterator of structures in the user-selected file, honoring the range, is specified.

Returns: Iterator of structure.Structure
Iterator of structures in the specified file.

addCallback(self, callback_adder, method)

 

Add a callback for a method - quietly do nothing if such callback already exists. Example: self.addCallback(maestro.workspace_changed_function_add, self.wsChanged)

This method tracks callbacks that are added for easy removal later. This tracking is done because Maestro prints an uncatchable WARNING to the terminal if we try to remove a callback that has not been added.

Parameters:
  • callback_adder (callable) - A callable function that adds a callback, such as maestro.workspace_changed_function_add
  • method (callable) - The method to use as the callback function.

browseFiles(self)

 

Callback method of the file browse button. Pops up a askopenfilename file selector and places the selected file name into the file text field

getFile(self)

 

Return the contents of the filename entry field. Returns "" if this is called while file input is not allowed.

getFiles(self)

 

Return the list of file names from the file entry field. This is a true list, not a comma-separated list.

getParams(self)

 

If the current GUI state isn't valid, pop up an error message and return None. Otherwise, return a JobInputParams object with the input source type and filename (if FILE source).

getSelectedEntryInfo(self)

 

Track the selected entries and emit input_changed if the set of selected entries changes. Also emit only_inclusion_changed if the set of selected entries remains the same but the inclusion state of some of the selected entries changes.

hideEvent(self, event)

 

Deregister callbacks when the panel hides itself so that we are not monitoring changes when the panel is inactive.

Parameters:
  • event (QHideEvent) - The QEvent object generated by this event
Returns:
The return value of the QFrame hideEvent method
Overrides: PyQt4.QtGui.QWidget.hideEvent

removeAllCallbacks(self)

 

Remove any previously added callbacks. We need to track callbacks in this manner because Maestro prints a WARNING message to the terminal if a non-registered callback is attempted to be removed.

removeCallback(self, callback_adder, method)

 

Remove a callback that may have been registered previously - silently do nothing if the callback isn't registered. We need to track callbacks in this manner because Maestro prints a WARNING message to the terminal if a non-registered callback is attempted to be removed.

Parameters:
  • callback_adder (callable) - A callable function that adds a callback, such as maestro.workspace_changed_function_add. This adder and its remover must be entered into the callback_removers dictionary.
  • method (callable) - The method to use as the callback function.

setFile(self, filename)

 

Select the specified filename in the input selector. To specify multiple files, separate them using commas. "File" or "Files" will be selected as the input source as appropriate.

Parameters:
  • filename (str) - The name of the file or files to select
Raises:
  • RuntimeError - If the file entry input state is not avaiable.
  • ValueError - If multiple files were provided, but the multiple files input state is not available.

setInputState(self, input_state)

 

Set the input type.

Parameters:
  • input_state (str) - The input state to change to. It must one of FILE, SELECTED_ENTRIES, INCLUDED_ENTRIES, INCLUDED_ENTRY, or WORKSPACE.
Raises:
  • ValueError - If the specified input type is not present

setup(self, jobparam)

 

This method serializes the input structure(s) to disk and stores the
name of the file in the jobparam instance.  Returns False (i.e.,
aborts the setup cascade) if no input structure file is written.
Otherwise, returns True.

Job parameters set by this method are...

    inputstrucsource -   The input source type that was used (FILE,
                         SELECTED_ENTRIES, INCLUDED_ENTIRES,
                         INCLUDED_ENTRY, or WORKSPACE).

    If "writefile" is True (default):
      If "multiplefiles" is True:
        inputstrucfiles -    The names of the created structure files when
                             multiplefiles is False. If source is FILE, then
                             it's the original paths specified by the user.
      If "multiplefiles" is False:
        inputstrucfile -     The name of the created structure file
                             ( <jobname>.<ext> ) when multiple files is False
        inputstrucorigfile - For FILE source, the path to the original
                             structure file selected.
        NOTE: if "copyfile" is set to False, the "inputstrucfile" is set to
        the same value as the "inputstrucorigfile"

    If "writefile" is False:
        inputstruc -         Structure object if source is WORKSPACE or
                             INCLUDED_ENTRY.
        inputstrucfile -     Path to specified structures if source is
                             FILE and multiplefiles is False.
        inputstrucfiles -    List of paths to specified structure files,
                             if source is FILE and multiplefiles is True.

Unused parameters are set to None.

showEvent(self, event)

 

Make sure the proper signals are emitted and proper callbacks are registered when the panel shows itself

Parameters:
  • event (QShowEvent) - The QEvent object generated by this event
Returns:
The return value of the QFrame showEvent method
Overrides: PyQt4.QtGui.QWidget.showEvent

structures(self, validate=True)

 

A generator that returns the user-specified input structures one at a time.

API Example:

   # appframework1
   for struct in self._if.structures():
       do something
   # appframework2
   for struct in self.input_selector.structures():
       do something
Parameters:
  • validate (bool) - Validate that the JobInputFrame is in a consistent and complete state (rows are actually selected or file is specified, etc.) Pops up a warning dialog and returns if the input is empty or invalid. Default is True. Useful to turn off if being called while the user might still be interacting with the panel.

updateInput(self, result)

 

Callback method of the input option menu. Disables the file selector and entry field if that is not the source chosen.

If tracking is on, this also checks to see if the set of structures selected for input has changed and sets up callbacks to continue tracking this information.

Parameters:
  • result (int) - The current index of the input combobox - unused

validate(self)

 

Validate that the JobInputFrame is in a consistent and complete state. Pops up a warning dialog and returns ERROR if the input is empty or invalid.

Returns: int
class constant ERROR if no structures are specified (i.e. the source is set to FILE but there is no specified file name, source is selected entries and no entries are selected, etc.) or otherwise invalid. Otherwise it returns class constant OK.

workspaceChanged(self, what_changed)

 

Emit input_changed if the Workspace change merits is

Parameters:
  • what_changed (maestro module constant (str)) - Description of what changed

writePTEntries(self, filename, warn=False, append=False, source='Project Table (selected entries)')

 

Write selected Project Table entries to 'filename'.

append - If True, the structures will be appended to an existing file;
        otherwise, the existing file is overwritten.

warn - Obsolete. Warning is no longer issued when the file exists

Raises a RuntimeError on error.
Returns False if the user cancelled.
Returns True on success.

writeSelectedEntries(self, filename, warn=False, append=False)

 

For backwards-compatability. Use the writePTEntries() method instead.


Class Variable Details [hide private]

INCLUDED_STATES

Value:
set(['Workspace (included entries)', 'Workspace (included entry)'])