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

Module appframework


This module provides GUI classes that mimic Maestro panels and dialogs.  The
main class is AppFramework for running Python applications with a Maestro
look-and-feel.  It provides a menu, standard buttons (Start, Write, Reset), a
Start dialog, a Write dialog, a input source selector, and methods for adding
all the relevant job parameters to a single object (used by the user when
creating input files and launching jobs).  The StartDialog and WriteDialog
actually can be used independently of AppFramework, in case a user doesn't
require a full Maestro-like panel.  There also is an AppDialog class for a
Maestro-like dialog (i.e., with buttons packed in the lower right corner).

PyQt Note: You can specify the QtDesigner-generated form via the <ui> argument.
Widgets defined within that form are automatically included in the window. The
form should be read from the *_ui.py file as follows:
    import <my_script_ui>
    ui = my_script_ui.Ui_Form()


There are two main ways to use AppFramework -- make an instance of the class,
or derive your own class from it.  For example...

----------
class MyGUI(schrodinger.ui.appframework.AppFramework):
    def __init__(self):
        buttons = {
            'start':{'command':self.start,'precommand':self.sanityCheck},
            'write':{'command':self.write,'precommand':self.sanityCheck},
            'reset':{'command':self.setDefaults},
            'close':{'command':self.quit}
            'help':{'command':self.help}
        }
        dialogs = {
            'start':{'jobname':'myjobname','cpus':True,'njobs':True},
            'write':{'jobname':'myjobname'}
        }
        schrodinger.ui.appframework.AppFramework.__init__(
            self,
            ui = my_script_ui.Ui_Form(),
            title="My application",
            buttons=buttons,
            dialogs=dialogs,
            inputframe={
                'support_mae' : True,
            }
        )

    def start(self):
    def write(self):
    def sanityCheck(self):
    def reset(self):
    def quit(self):
    def help(self):
----------

...or...

----------
my_app = schrodinger.ui.appframework.AppFramework(
    title = "My application",
    ui = my_script_ui.Ui_Form(),
    buttons = {
        'start':{'command':start_app,'precommand':sanity_check},
        'write':{'command':write_app,'precommand':sanity_check},
        'reset':{'command':set_app_defaults},
        'close':{'command':quit_app},
        'help':{'command':help_app}
    },
    dialogs = {
        'start':{'jobname':'myjobname','cpus':True,'njobs':True},
        'write':{'jobname':'myjobname'}
    },
    inputframe={
        'filetypes':[('Maestro Files','*.mae'),('SD Files','*.sdf')]
    }

def start_app():
def write_app():
def sanity_check():
def reset_app():
def set_app_defaults():
def quit_app():
def help_app():
----------

Of course, the second approach could be done within a class of its own, with
the button callback functions being methods of the class.


The AppFramework is configured via button and dialog dictionaries.  Each key
is a button or dialog type, and the value is a further dictionary of the
configurable attributes of the button/dialog.  The most critical attribute of
buttons is the callback command.  AppFramework calls this command when the
button is pressed, though it may take other actions first (e.g., bringing up
a dialog).  The dictionary for a particular dialog is used as keyword
arguments when creating the *Dialog instance.  The 'inputframe' is an
additional AppFramework GUI element that is configured separately from the
buttons and dialogs, but also through a dictionary.  Menus (not shown in the
examples) also can be configured (see the AppFramework documentation).

AppFramework places key job information (e.g., the jobname and host from the
StartDialog) into a JobParameters object that is stored as the 'jobparam'
attribute.  When the user's start or write method is called, retrieve the
needed job information from that object.

AppFramework provides a method for application-specific job data to be placed
into the JobParameters object.  Suppose the user's GUI is modular, with
several frames responsible for various parameters of the job.  Any object
that has a 'setup' method can be registered with the AppFramework object, and
this method will be called as part of the setup cascade that occurs when the
Start or Write button is pressed.  To register an object, append the object to
the AppFramework's 'setup' list.  The JobParameters object will be passed to
the registered object via the 'setup' method.  The 'setup' method should
return True if the setup cascade should continue (i.e., there are no
problems).

See the AppFramework, *Dialog, and JobInputFrame classes for explanations of
the various AppFramework configuration options.

The StartDialog can be used directly.  For example...

----------
sd = schrodinger.ui.appframework.StartDialog(
    parent_frame,
    jobname='myjobname',
    title='My application',
    cpus=True
)
sd_params = sd.activate()
----------

The 'sd_params' is a StartDialogParams object whose attributes are the job
parameters set up via the StartDialog.  In AppFramework, the StartDialogParams
attributes are copied into the JobParameters object.


Once you have setup the AppFramework you can add your own widgets to the
central area with 'addCentralWidget()'. Typically you'd create a QWidget
(QFrame or QGroupBox) containing everything you need and add that just once.
If QtDesigner was used to create a layout, then instead of using
addCentralWidget(), give the form to the constructor via the 'ui' argument.

Copyright Schrodinger, LLC. All rights reserved.

Classes [hide private]
  AppDockWidget
A DockWidget that calls the parent class's closeEvent when closing
  AppFramework
The AppFramework class is basically a hull for applications.
  ColoredTableItem
  ConfigDialog
Toplevel Qt widget that mimics the Maestro Start dialog.
  CustomProgressBar
Class for a custom progress bar (at the bottom of some panels).
  DialogParameters
Class for holding dialog parameters.
  DontShowAgainDialog
Dialog that displays information for the user and contains a Don't Show This again checkbox
  GPGPUConfigDialog
This Config Dialog supports enumerating GPGPU's and allowing the user to select which GPGPU(s) they'd like to use.
  Gpu
  Host
Extension of jobcontrol.Host class with GPUs.
  JobInputFrame
An application input source selection widget.
  JobInputParams
A class to store the state of the JobInputFrame, and to control behavior needed to create access to structure files.
  JobParameters
Class for holding job parameters.
  JobStatusToolButton
  JobTable
  MonitorDropdown
A menu-derived object which exists solely as an adapter to allow the mini- monitor to be dropped out of the job status toolbutton.
  MultiGPGPUConfigDialog
Subclass for selecting multiple GPGPU's
  MultiHostSelector
Widget that contains a table for selecting multiple hosts.
  MultiHostTableModel
Model for the hosts table.
  PopUpWidget
  ReadDialog
Dialog allowing user to specify a file to read in.
  StartDialog
  StartDialogParams
A collection of parameter values from the StartDialog class.
  TestApp
Class for testing AppFramework outside of Maestro.
  WriteDialog
Toplevel Qt widget that mimics the Write dialog.
  _EntryField
A special composite widget which contains a labeled line edit field.
  _ToolButton
Functions [hide private]
 
filter_string_from_supported(support_mae, support_sd, support_pdb)
list
form_jaguar_cpu_flags(host, cpus, subjobs, threads, use_parallel_flag=True)
Determine the command line flags for an Open MP job.
 
format_list_to_filter_string(filetypes)
Converts Tkinter-style file types list to Qt-style filter string
list
get_hosts(ncpus=True, excludeGPGPUs=True)
Return a list of Host objects for use in config dialogs.
str
get_next_jobname(prefix, starting_num=1)
Given a job name prefix, choose the next available job name based on the names of existing files in the CWD.
int or None
get_num_nprocs(cd_params)
Get the number of processes requested by the user
 
get_workspace_structure()
Returns the Workspace structure.
 
help_dialog(topic, product='Maestro', parent=None)
Display a help dialog (or a warning dialog if no help can be found).
 
is_jobname_retain_set()
Returns True if the "Retain last job name used" option is set in Maestro preferences.
 
make_desres_about_button(parent)
Generate the about button with copyright information for DESRES panels.
 
make_desres_layout(product_text='', flip=False, vertical=False)
Generate a QLayout containing the Desres logo and Schrodinger product info
 
question(msg, button1='OK', button2='Cancel', parent=0, title='Question')
Display a prompt dialog window with specified text.
 
test()
Variables [hide private]
  BOTTOM_DOCK_AREA = 8
  BOTTOM_TOOLBUTTON_HEIGHT = 24
  CRITICAL = 'critical'
  DESRES_COPYRIGHT_INFO = 'Desmond Molecular Dynamics System, Co...
  DISP_APPEND = 'Append new entries'
  DISP_FLAG_FIT = 'fit'
  DISP_FLAG_SEPARATOR = ':'
  DISP_IGNORE = 'Do not incorporate'
  DISP_NAMES = OrderedDict([('append', 'Append new entries'), ('...
  FILE = 'file'
  HELP_BUTTON_HEIGHT = 22
  INCLUDED_ENTRIES = 'included_entries'
  INCLUDED_ENTRY = 'included_entry'
  INFORMATION = 'information'
  LEFT_DOCK_AREA = 1
  LOCALHOST = 'localhost'
hash(x)
  LOCALHOST_GPU = 'localhost-gpu'
  PYHELP_ERROR_MSG = 'The help topic for this panel could not be...
  RIGHT_DOCK_AREA = 2
  SELECTED_ENTRIES = 'selected_entries'
  TOP_DOCK_AREA = 4
  WARNING = 'warning'
  WORKSPACE = 'workspace'
  __package__ = 'schrodinger.ui.qt'
  _version = '$Revision: 1.32 $'
  maestro = None
hash(x)
Function Details [hide private]

form_jaguar_cpu_flags(host, cpus, subjobs, threads, use_parallel_flag=True)

 

Determine the command line flags for an Open MP job.

Parameters:
  • host (str) - The host name
  • cpus (int) - The number of CPUs requested. If subjobs and threads are non-zero, this value will be equal to subjobs * threads and can be ignored.
  • subjobs (int) - The number of subjobs requested. Will be 0 if the user only specified the total number of CPUs.
  • threads (int) - The number of threads requested. Will be 0 if the user only specified the total number of CPUs.
  • use_parallel_flag (bool) - Whether requesting CPUs > 1 without specifying threads > 1 should be represented by the use of the -PARALLEL X flag (True) or -HOST host:X (False). -PARALLEL is a Jaguar flag and may not be appropriate for other programs.
Returns: list
The appropriate command line flags.

get_hosts(ncpus=True, excludeGPGPUs=True)

 

Return a list of Host objects for use in config dialogs. Note these are a subclass of jobcontrol.Host which has additional features for text labels and accounting for GPUs. If schrodinger.hosts file is missing, only localhost will be returned. If it is unreadable, then an error message will be shown in a dialog box, and an empty list will be returned.

Parameters:
  • ncpus (bool) - whether host text labels should include number of processors
  • excludeGPGPUs (bool) - whether to exclude GPU hosts from the list
Returns: list
a list of Host objects

get_next_jobname(prefix, starting_num=1)

 

Given a job name prefix, choose the next available job name based on the names of existing files in the CWD.

Parameters:
  • starting_num (int) - The smallest number to append to the job name
Returns: str
The completed job name

get_num_nprocs(cd_params)

 

Get the number of processes requested by the user

Parameters:
Returns: int or None
The number of CPUs requested by the user if they are using the CPUs option, or the number of simultaneous subjobs if they are using the MP subjobs option. Or None if neither of these are specified.

get_workspace_structure()

 

Returns the Workspace structure. If only one entry is in workspace, then the properties are included as well.

help_dialog(topic, product='Maestro', parent=None)

 

Display a help dialog (or a warning dialog if no help can be found).

Parameters:
  • topic (str) - The topic to display help for
  • help_product - The help product to access. Defaults to "Maestro".
  • parent (QWidget) - The parent of the warning dialog. If not given, no parent is used.
  • product (str)

make_desres_about_button(parent)

 

Generate the about button with copyright information for DESRES panels.

Parameters:
  • parent (QWidget) - The parent widget (the panel)

make_desres_layout(product_text='', flip=False, vertical=False)

 

Generate a QLayout containing the Desres logo and Schrodinger product info

Parameters:
  • product_text (str) - Name of Schrodinger product to add opposite the DESRES logo
  • flip (bool) - whether to reverse the two logos left/right
  • vertical (bool) - whether to display the logos stacked vertically or side by side horizontally

question(msg, button1='OK', button2='Cancel', parent=0, title='Question')

 

Display a prompt dialog window with specified text. Returns True if first button (default OK) is pressed, False otherwise.


Variables Details [hide private]

DESRES_COPYRIGHT_INFO

Value:
'''Desmond Molecular Dynamics System, Copyright (c) 2004-2014 D. E. Sh\
aw Research.
Portions of Desmond Software, Copyright (c) Schrodinger, LLC.
All rights reserved.'''

DISP_NAMES

Value:
OrderedDict([('append', 'Append new entries'), ('ignore', 'Do not inco\
rporate')])

PYHELP_ERROR_MSG

Value:
'The help topic for this panel could not be found.'