Ticket #3636: trac3636_2.patch

File trac3636_2.patch, 2.2 kB (added by itolkov, 4 months ago)
  • a/sage/server/notebook/interact.py

    old new  
    14731473        ...     show(plot(sin(a*x+b), (x,0,6)), figsize=3) 
    14741474        <html>... 
    14751475 
     1476    Place a block of text among the controls: 
     1477        sage: @interact 
     1478        ... def _(t1=text_control("Factors an integer."), n="1"): 
     1479        ...     print factor(Integer(n))    
     1480        <html>... 
     1481     
    14761482    You do not have to use interact as a decorators; you can also 
    14771483    simply write \code{interact(f)} where f is any Python function 
    14781484    that you have defined, though this is frowned on.  E.g., f can 
     
    14841490    DEFAULTS: 
    14851491    Defaults for the variables of the input function determine 
    14861492    interactive controls.  The standard controls are \code{input_box}, 
    1487     \code{slider}, \code{checkbox}, \code{selector}, and 
    1488     \code{input_grid}.  There is also a color selector (see defaults below). 
     1493    \code{slider}, \code{checkbox}, \code{selector},  
     1494    \code{input_grid}.  There is also a color selector and text control 
     1495    (see defaults below). 
    14891496     
    14901497    \begin{itemize} 
    14911498        \item u = input_box(default=None, label=None, type=None) 
     
    15011508        \item u = input_grid(nrows, ncols, default=None, label=None, 
    15021509                             to_value=lambda x:x, width=4) 
    15031510                         -- an editable grid of objects (a matrix or array) 
    1504  
     1511        \item u = text_control(value='') 
     1512                         -- a block of text 
    15051513    \end{itemize} 
    15061514 
    15071515    You can create a color selector by setting the default value for a 
     
    23892397                        buttons=self.__buttons) 
    23902398     
    23912399class text_control(control): 
    2392     def __init__(self, value): 
     2400    def __init__(self, value=''): 
    23932401        """ 
    23942402        Text that can be inserted among other interact controls. 
    23952403