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

Class AppFramework

   Tkinter.Misc --+        
                  |        
     Tkinter.Wm --+        
                  |        
         Tkinter.Tk --+    
                      |    
widget.tkinterwidget.Tk --+
                          |
                         AppFramework

The AppFramework class is basically a hull for applications.

With its own instance of a DialogParameters class, Application manages Schrodinger dialogs like start, read, and write so that the programmer is free to worry about other things. The dialogs can be manipulated at anytime to fit the needs of the programmer (please see the DialogParameters class below).

The Application class also comes with an instance of the JobParameters class (jobparam). This object is intended to be used to store all GUI settings. Please see the JobParameters class below for more information on proper usage.

In addition to these features, the AppFramework class can take arguments for Main Menu creation.

Supposing I wanted a menu of the form:

   File      Edit              Help
   ^Save     ^Options          ^About
   ^Close    ^^First Option
             ^^Second Option

When I create my AppFramework instance, I would pass the following keyword, value pair:

   menu = {1: ["File", "Edit", "Help"],
           "File": {"Save": {"command": <command_here>},
                    "Close": {"command": <command_here>},
                    },
           "Edit": {"Options": {"First Option": {"command": <command_here>},
                                "Second Option": {"command": <command_here>},
                                },
                    },
           "Help": {"About": {"command": <command_here>},
                    },
           }

The dictionary key 1 (int form, not string form) is the key for an ordering list. Because dictionaries are not ordered, this is needed to specify your prefered order.

AppFramework also manages the Bottom Button Bar. One more keyword for the AppFramework instance is "buttons", and would appear like:

   buttons = {"start": {"command": <command_here>},
                        "dialog": <boolean_show_dialog?>},
              "read": {"command": <command_here>},
              "write": {"command": <command_here>,
                        "dialog": <boolean_show_dialog?>},
              "reset": {"command": <command_here>},
              "close": {"command": <command_here>},
              "help": {"command": <command_here>},
              }

The six supported buttons are "start", "read", "write", "reset", "close", and "help". Any button name for which you supply a command will be created and placed in the correct location.

Non-default button names can be used by supplying a 'text' keyword.

You can also specify a command for start, read, and write buttons that will be called when the button is pressed before displaying the dialog with the 'precommand' keyword. For example, you may want to check an input before allowing the start dialog to appear. These functions should return 0 unless the dialog should not be displayed (nor the specified start/read/write function called). Any function that returns a non-zero value will halt the dialog process, and return to the GUI.

Before the user supplied command is called, if there is an associated dialog, the AppFramework presents the dialog, saves the input in the jobparam object mentioned above. Then AppFramework calls the command.

Button configuration options are:

Finally, there is an Input Frame that can be used. Please see that class below for information on proper use.

Nested Classes [hide private]

Inherited from Tkinter.Misc: getdouble, getint

Instance Methods [hide private]
 
__init__(self, **kwargs)
See class docstring.
 
interior(self)
Return the interior frame where widgets should be added
 
createMenus(self, dict)
Setup for making individual menus, create MainMenuBar.
 
_makeMenu(self, menuname, dict)
Create the menu <menuname>
 
_createMenuItem(self, menuname, itemname, dict)
Setup the item <itemname> of menu <menuname>.
 
_makeItem(self, menuname, itemname, dict)
Create individual item in a menu.
 
_setButtonDefaults(self, button, default_name, default_dialog)
Sets defaults for unspecified button options and adds ellipses to the button text if it brings up a dialog.
 
_setupBottomButtons(self, **_buttonDict)
Create the requested bottom buttons, configured according to the 'buttonDict'.
 
_start(self)
Method for start button.
 
_read(self)
Method for read button.
 
_write(self)
Method for write button.
 
_reset(self)
Method for reset button.
 
setButtonState(self, button, state)
Set the state of the specified button, e.g.,
 
setupJobParameters(self)
Invoke setup() for every class in the setup list
 
getJobParameters(self, widget)
Invoke setup() for specific widget, return options in a new JobParameters object
 
monitorJob(self, jobid, showpanel=True)
Monitor the given jobid and show the monitor panel; if in maestro.
 
error(self, text)
Display an error window with the specified text.
 
warning(self, text)
Display a warning window with the specified text.
 
info(self, text)
Display an info window with the specified text.
 
question(self, question, button1="OK", button2="Cancel")
Display a prompt dialog window with specified text.
 
askOverwrite(self, files=None)
Display a dialog asking the user whether to overwrite existing files.
 
askOverwriteIfNecessary(self, files)
If any of the files in the <files> list exists, will bring up a dialog box asking the user whether they want to overwrite them.

Inherited from widget.tkinterwidget.Tk: destroy, mainloop, tofront

Inherited from widget.tkinterwidget.Tk (private): _quit

Inherited from Tkinter.Tk: __getattr__, loadtk, readprofile, report_callback_exception

Inherited from Tkinter.Tk (private): _loadtk

Inherited from Tkinter.Misc: __contains__, __getitem__, __setitem__, __str__, after, after_cancel, after_idle, bbox, bell, bind, bind_all, bind_class, bindtags, cget, clipboard_append, clipboard_clear, clipboard_get, colormodel, columnconfigure, config, configure, deletecommand, event_add, event_delete, event_generate, event_info, focus, focus_displayof, focus_force, focus_get, focus_lastfor, focus_set, getboolean, getvar, grab_current, grab_release, grab_set, grab_set_global, grab_status, grid_bbox, grid_columnconfigure, grid_location, grid_propagate, grid_rowconfigure, grid_size, grid_slaves, image_names, image_types, keys, lift, lower, nametowidget, option_add, option_clear, option_get, option_readfile, pack_propagate, pack_slaves, place_slaves, propagate, quit, register, rowconfigure, selection_clear, selection_get, selection_handle, selection_own, selection_own_get, send, setvar, size, slaves, tk_bisque, tk_focusFollowsMouse, tk_focusNext, tk_focusPrev, tk_menuBar, tk_setPalette, tk_strictMotif, tkraise, unbind, unbind_all, unbind_class, update, update_idletasks, wait_variable, wait_visibility, wait_window, waitvar, winfo_atom, winfo_atomname, winfo_cells, winfo_children, winfo_class, winfo_colormapfull, winfo_containing, winfo_depth, winfo_exists, winfo_fpixels, winfo_geometry, winfo_height, winfo_id, winfo_interps, winfo_ismapped, winfo_manager, winfo_name, winfo_parent, winfo_pathname, winfo_pixels, winfo_pointerx, winfo_pointerxy, winfo_pointery, winfo_reqheight, winfo_reqwidth, winfo_rgb, winfo_rootx, winfo_rooty, winfo_screen, winfo_screencells, winfo_screendepth, winfo_screenheight, winfo_screenmmheight, winfo_screenmmwidth, winfo_screenvisual, winfo_screenwidth, winfo_server, winfo_toplevel, winfo_viewable, winfo_visual, winfo_visualid, winfo_visualsavailable, winfo_vrootheight, winfo_vrootwidth, winfo_vrootx, winfo_vrooty, winfo_width, winfo_x, winfo_y

Inherited from Tkinter.Misc (private): _bind, _configure, _displayof, _getboolean, _getdoubles, _getints, _grid_configure, _nametowidget, _options, _register, _report_exception, _root, _substitute

Inherited from Tkinter.Wm: aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconposition, iconwindow, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, state, title, transient, withdraw, wm_aspect, wm_attributes, wm_client, wm_colormapwindows, wm_command, wm_deiconify, wm_focusmodel, wm_frame, wm_geometry, wm_grid, wm_group, wm_iconbitmap, wm_iconify, wm_iconmask, wm_iconname, wm_iconposition, wm_iconwindow, wm_maxsize, wm_minsize, wm_overrideredirect, wm_positionfrom, wm_protocol, wm_resizable, wm_sizefrom, wm_state, wm_title, wm_transient, wm_withdraw

Class Variables [hide private]

Inherited from Tkinter.Tk (private): _w

Inherited from Tkinter.Misc: _noarg_

Inherited from Tkinter.Misc (private): _subst_format, _subst_format_str, _tclCommands

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

 

See class docstring.

Overrides: Tkinter.Tk.__init__

_createMenuItem(self, menuname, itemname, dict)

 

Setup the item <itemname> of menu <menuname>. Creates the item or cascading menu.

_setButtonDefaults(self, button, default_name, default_dialog)

 

Sets defaults for unspecified button options and adds ellipses to the button text if it brings up a dialog. Raises a SyntaxError if no command is specified for the button in the button dictionary.

_start(self)

 

Method for start button. Show dialog, process results, call command.

_read(self)

 

Method for read button. Show dialog, process results, call command.

_write(self)

 

Method for write button. Show dialog, process results, call command.

_reset(self)

 

Method for reset button. Reset file input frame, call command.

setButtonState(self, button, state)

 

Set the state of the specified button, e.g.,

self.setButtonState('start', 'disabled')

The standard state is 'normal'. Raises a RuntimeError if the button doesn't exist or if the requested state can't be set.

setupJobParameters(self)

 

Invoke setup() for every class in the setup list

Every widget in the self.setup list gets a chance to modify the appropriate values (e.g. forcefield to use, or receptor file) in the JobParameters() instance (jobparam) before the start or write functions are called.

Returns True if all setup() commands return True (i.e., success). Returns False otherwise.

getJobParameters(self, widget)

 

Invoke setup() for specific widget, return options in a new JobParameters object

Return new JobParameters instance with only options from specified widget. This is useful to retrieve arguments for a specific widget, if you only needed those arguments.

Return None if setup unsuccessful

monitorJob(self, jobid, showpanel=True)

 

Monitor the given jobid and show the monitor panel; if in maestro.

jobid - jobid of the job to monitor showpanel - whether to bring up the Monitor panel (default True)

Example: After launching the job, use the jobid to issue the command:

<AppFramework_instance>.monitorJob(<jobid>)

question(self, question, button1="OK", button2="Cancel")

 

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

askOverwrite(self, files=None)

 

Display a dialog asking the user whether to overwrite existing files. Returns True if user chose to overwrite, False otherwise.

Optionally specify a list of files that will be overwritten if the user presses the Overwrite button.

askOverwriteIfNecessary(self, files)

 

If any of the files in the <files> list exists, will bring up a dialog box asking the user whether they want to overwrite them. Returns True if the user chose to overwrite or if specified files do not exist. Returns False if the user cancelled.