Ticket #3121: sage-3121-part2_doc.patch

File sage-3121-part2_doc.patch, 4.5 KB (added by was, 13 years ago)

this cleans up the docs a little bit and adds some consistency. apply after the other patch

  • sage/server/notebook/interact.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1210474441 25200
    # Node ID eec6e44c279adeb4dd276879060b2acafdf52c1a
    # Parent  265aef329367e74d504f4f27d8647023efba02fb
    trac #3121 -- slight followup doc patch
    
    diff -r 265aef329367 -r eec6e44c279a sage/server/notebook/interact.py
    a b VERSION 2: 
    115115          maxlength -- the maximum number of characters allowed in a text field.
    116116          name -- defines a unique name for the input element
    117117          size -- the size of the input element
    118           type -- button, checkbox, file, password, radio, slider, text, setter_bar, drop_down
     118          type -- button, checkbox, file, password, radio, slider, text, setter_bar
    119119
    120120VERSION 3:
    121121   [ ] protocol for objects to have their own interact function; make
    def interact(f): 
    11741174    DEFAULTS:
    11751175    Defaults for the variables of the input function determine
    11761176    interactive controls.  The standard controls are \code{input_box},
    1177     \code{slider}, \code{button}, \code{checkbox}.
     1177    \code{slider}, \code{checkbox}, \code{selector}, and
     1178    \code{input_grid}.  There is also a color selector (see defaults below).
    11781179   
    11791180    \begin{itemize}
    1180         \item u = input_box(default, label, type=None)
     1181        \item u = input_box(default=None, label=None, type=None)
    11811182                         -- input box with given default; use type=str to
    11821183                            get input as an arbitrary string
    1183         \item u = slider(vmin, vmax,step_size,default,label)
     1184        \item u = slider(vmin, vmax=None,step_size=1,default=None,label=None)
    11841185                         -- slider with given list of possible values; vmin an be a list
    1185         \item u = checkbox(default, label)
     1186        \item u = checkbox(default=True, label=None)
    11861187                         -- a checkbox
    11871188        \item u = selector(values, label=None, nrows=None, ncols=None, buttons=False)                 
    11881189                         -- a dropdown menu or buttons (get buttons if nrows,
    11891190                            ncols, or buttons is set, otherwise a dropdown menu)
    1190         \item u = drop_down(list, label)
    1191                          -- a drop down menu
     1191        \item u = input_grid(nrows, ncols, default=None, label=None,
     1192                             to_value=lambda x:x, width=4)
     1193                         -- an editable grid of objects (a matrix or array)
     1194
    11921195    \end{itemize}
    11931196
    11941197    You can create a color selector by setting the default value for a
    def interact(f): 
    12121215        \item u = Color('blue') -- a 2d RGB color selector; returns Color object
    12131216        \item u = (default, v)  -- v as above, with given default value
    12141217        \item u = (label, v)    -- v as above, with given label (a string)
    1215         \item u = matrix        -- an input_grid with to_value set to matrix.parent() and the default values given by the matrix
     1218        \item u = matrix        -- an input_grid with to_value set to matrix.parent()
     1219                                   and default values given by the matrix
    12161220    \end{itemize}
    12171221
    12181222    WARNING: Suppose you would like to make a interactive with a
    class input_box(control): 
    15471551
    15481552
    15491553class input_grid(control):
    1550     def __init__(self, rows, columns, default=None, label=None, to_value=lambda x: x, width=4):
     1554    def __init__(self, nrows, ncols, default=None, label=None, to_value=lambda x: x, width=4):
    15511555        r"""
    15521556        An input grid interactive control.  Use this in conjunction
    15531557        with the interact command.
    15541558
    15551559        INPUT:
     1560            nrows -- integer
     1561            ncols -- integer
    15561562            default -- object; the default put in this input box
    15571563            label -- the label rendered to the left of the box.
    15581564            to_value -- the grid output (list of rows) is sent through
    1559             this function.  This may reformat the data or coerce the
    1560             type.
     1565                        this function.  This may reformat the data or
     1566                        coerce the type.
    15611567            width -- size of each input box in characters
    15621568           
    15631569        NOTEBOOK EXAMPLE:
    class input_grid(control): 
    15851591
    15861592        """
    15871593        self.__default = default
    1588         self.__rows = rows
    1589         self.__columns = columns
     1594        self.__rows = nrows
     1595        self.__columns = ncols
    15901596        self.__to_value = to_value
    15911597        self.__width = width
    15921598        control.__init__(self, label)