____________________________________________________

WHAT DO YOU NEED TO CREATE AN INPUTFORM IN PMV
____________________________________________________



  1. THE INPUTFORMDESCR CLASS:
  2. InputFormDescr is a list of dictionary describing the widgets to be placed in an inputform.
    Such an object can be passed to an InputForm object to actually build an InputForm

    The dictionnary can contain the following key:value couples:

    • widgetType:
      This specifies the type of the widget. It is usually a class name that can be any of the following
      • any Tkinter widget (Tkinter.Button etc....)
      • any CustomizedWidgets widgets (ListChooser, Dial etc....)
      • any of the Pmw widgets (Pmw.EntryFields....)
    • name
    • string to specify a name associated to the widget. This name is then used to create the value dictionary.
    • tooltip
    • string describing the widget which will be displayed in a balloon when the mouse is over it.
    • wcfg
    • The widget configuration dictionary must contain all the couple keyword:value you want to use to describe your widget. For a list of the option available to describe widgets:
    • gridcfg
      The grid configuration dictionary specifies where in the form the current widget will be placed. It contains keyword:value where the keys are the option of the Tkinter grid manager. The value of the row and column can be negative if you want to place your widget several row or column before the last one. The position of the widget will be found by the function findGridPosition. If no row or column is specified it will place your widget after the last one according to the specified direction you want your inputform to be built.You can't leave an empty space between two widgets.
    • container
      dictionary specifying the current widget or part of the current widget as a container.
      • key :(string) name of the container. This name will then be used to specify their parent
      • value : instance of the container or a string that will be evaluated and the result of which will be the container. 'container':{'Page1':'w.page('Page1')}, example: Notebook widget with two pages Page1 and Page2 'container':{'Page1':'w.page('Page1')', 'Page2':'w.page('Page2')' Frame 'container':{'myFrame':'w'} (see colorCommands.py, APBSCommand.py, fileCommands for examples)
    • parent
      allows to specify in which container to pack the current widget.(see colorCommands.py, APBSCommand.py, fileCommands for example)
    • componentcfg:
      dictionnary allowing the developer to describe the components of the current widget.
      • key : is the name of the component
      • value : description of the widget (see APBSCommand for an example)
    • defaultValue: The given defaultValue is used to initialize the widget if it has a bound variable or if the widget has a set method.
    • type :The keyword type is used to check the validity of the data the user gives (it is a string by default).
    • required : (1 or 0) The keyword required is flag to specify whether or not this field is required.

  3. THE INPUTFORM CLASS:
  4. The InputForm class provides support to build customized form for the user to fill out.

    Arguments of the InputForm constructor:

    required arguments:
    master
    container widget or the master of the widget to be created which means that the current form will be a 'slave' of the given master
    root
    If root is None then a Tkinter.TopLevel object will be created with the given master.
    descr
    (instance of InputFormDescr) which is a list of dictionaries describing the widgets to be added to the form.
    optional arguments :
    modal
    Flag to specify if the form is modal or not. When a form is modal it grabs the focus and only releases it when the form is dismissed. When a form is modal an OK and a CANCEL button will be automatically added to the form.
    (default = 1)
    blocking
    Flag to specify if the form is blocking or not. When set to 1 the form is blocking and the calling code will be stopped until the form is dismissed. An OK and a CANCEL button will be automatically added to the form. (default = 0)
    defaultDirection
    argument to specify the direction in which the widgets will be gridded in the form can be either 'row' or 'col' (default='row').
    closeWithWindow
    Flag to specify whether or not the form should be minimized/maximized when the master window is. (default=1)
    okCfg
    dictionnary to describe the appearance of the OK button. If a callback function is specified in the 'command' keyword then it will be executed in the OK_cb.
    cancelCfg
    dictionnary to describe the appearance of the CANCEL button. If a callback function is specified using the keyword command this callback will be executed by the Cancel_cb
    initFunc
    argument to specify a function to initialize the form.
    onDestroy
    argument to specify a function to be called when using the close widget of a window (usually the [X] at the right corner of a window)
    okcancel
    Boolean Flag to specify whether or not to create the OK and CANCEL button.
    scrolledFrame
    Flag to specify whether to use a Tkinter.Frame when set to 0 or a Pmw.ScrolledFrame when when set to 1.
    width
    argument to specify the width of the main frame (400)
    height
    argument to specify the height of the main frame. (200)
    help
    argument to specify an URL to a help page. When given a 'HELP' button will be created next to the OK/CANCEL button which will open a webbrowser to the given URL a Help (?) button will be created which will open a web browser to the given URL

    Examples:

    1. Creating a modal and blocking inputform:
    2. >>> from mglutil.gui.InputForm.Tk.gui import InputForm, InputFormDescr
      >>> import Tkinter, Pmw
      >>> descr = InputFormDescr(title="My First InputForm") >>> descr.append({'name':'display',
      'widgetType':Pmw.RadioSelect,
      'listtext':['display','display only', 'undisplay'],
      'defaultValue':'display',
      'wcfg':{'orient':'horizontal',
      'buttontype':'radiobutton'},
      'gridcfg':{'sticky': 'we'}})
      >>> form = InputForm(

    3. THE CALLBACKFUNCTION CLASS:
    4. The CallBackFunction class provides support to bind a callback function with arguments to your widget. The reference to the function and arguments (including keywords) that are passed to the CallBackFunction class are stored by its constructor and then passed on to the function when the callback is activated.

      - Example: Example showing how to use a CallBackFunction object:

         >>>from Framework.gui import InputFormDescr, InputForm, CallBackFunction
         >>>import Tkinter
         >>># 1- define the textvariable option of the Tkinter.Button which is a 
         >>>#    Tkinter.StringVar()and set it at GreenButton.
         >>>buttonvar = Tkinter.StringVar()
         >>>buttonvar.set("Green")
         >>># 2- Then Define the callbackfunction you want to call when you click
         >>>#    on the button.
         >>>def callback(vars)
         ...    buttonvar = vars[0]
         ...    # This function modifies the value of the buttonvar 
         ...    # variable, which has for consequence the modification of the 
         ...    # text in the button.
         ...
         ...    if buttonvar.get()=="Green":
         ...        buttonvar.set("Yellow")
         ...    elif buttonvar.get()=="Yellow":
         ...        buttonvar.set("Green")
         >>># 3- Then define your Button using InputFormDescr.
         >>>idf = InputFormDescr(title ="Button")
         >>>idf.append({'widgetType':Tkinter.Button,
         ...            'wcfg':{'width':10,'height':2,
         ...                    'textvariable':buttonvar,
         ...                    'command':CallBackFunction(callback,(buttonvar,))},
         ...            'gridcfg':{}})
         >>
         >>>form = InputForm(idf, modal=0, blocking=0)
         >>>form.go()
      
         


      __________________________________________________________