Changeset 4563

Show
Ignore:
Timestamp:
05/07/08 08:06:26 (7 months ago)
Author:
alberto
Message:

reorganized tw.forms docs and integrated widgetbrowser

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/ToscaWidgetsForms/trunk/docs/index.rst

    r4561 r4563  
    1313    
    1414   intro 
    15    widgets 
     15   tutorials/index 
    1616   modules/index 
    17    tutorials/index 
    1817 
    1918Indices and tables 
  • projects/ToscaWidgetsForms/trunk/docs/modules/calendar.rst

    r4540 r4563  
    11.. _calendars_module: 
    22 
    3 tw.forms.calendars 
    4 ================== 
     3:mod:`tw.forms.calendars` 
     4========================= 
    55 
    66.. automodule:: tw.forms.calendars 
    7    :members: 
     7    
     8   :class:`CalendarDatePicker` 
     9   --------------------------- 
    810 
     11   .. autoclass:: tw.forms.calendars.CalendarDatePicker 
     12   .. widgetbrowser:: tw.forms.calendars.CalendarDatePicker 
     13      :size: large 
    914 
     15   :class:`CalendarDateTimePicker` 
     16   ------------------------------- 
     17 
     18   .. autoclass:: tw.forms.calendars.CalendarDateTimePicker 
     19   .. widgetbrowser:: tw.forms.calendars.CalendarDateTimePicker 
     20      :size: large 
  • projects/ToscaWidgetsForms/trunk/docs/modules/core.rst

    r4540 r4563  
    11.. _core_module: 
    22 
    3 tw.forms.core 
    4 =============== 
     3:mod:`tw.forms.core` 
     4==================== 
    55 
    66.. automodule:: tw.forms.core 
    7    :members: 
     7    
     8    :class:`InputWidget` 
     9    -------------------- 
    810 
     11    This is the base class for all widgets that can submit input. It has the 
     12    machinery to validate and coerce the received data. 
     13 
     14      .. autoclass:: tw.forms.core.InputWidget 
     15         :members: adjust_value, validate, safe_validate, prepare_dict, post_init, name, error_at_request, value_at_request 
     16      
     17 
     18    :class:`InputWidgetRepeater` 
     19    ---------------------------- 
     20 
     21    This is the base class to create repeated InputWidgets. 
     22 
     23    .. autoclass:: tw.forms.core.InputWidgetRepeater 
  • projects/ToscaWidgetsForms/trunk/docs/modules/datagrid.rst

    r4540 r4563  
    11.. _datagrid_module: 
    22 
    3 tw.forms.datagrid 
    4 ================== 
     3:mod:`tw.forms.datagrid` 
     4======================== 
     5 
     6Widgets to present data in tabular form 
    57 
    68.. automodule:: tw.forms.datagrid 
    7    :members: 
     9 
     10   .. autoclass:: tw.forms.datagrid.DataGrid 
     11   .. widgetbrowser:: tw.forms.samples.DemoDataGrid 
     12      :size: large 
  • projects/ToscaWidgetsForms/trunk/docs/modules/index.rst

    r4561 r4563  
    44======= 
    55 
     6All public symbols are available at :mod:`tw.forms` and should be imported 
     7from there. 
     8 
    69.. toctree:: 
    7    :maxdepth: 3 
     10   :maxdepth: 2 
    811    
    912   core 
    10    fields 
     13   fields/index 
    1114   validators 
    1215   calendar 
  • projects/ToscaWidgetsForms/trunk/docs/modules/validators.rst

    r4540 r4563  
    11.. _validators_module: 
    22 
    3 tw.forms.validators 
    4 =================== 
     3:mod:`tw.forms.validators` 
     4========================== 
    55 
    66.. automodule:: tw.forms.validators 
  • projects/ToscaWidgetsForms/trunk/docs/tutorials/sample_form.rst

    r4540 r4563  
    77 
    88TODO: Explain how it is built and how it works 
    9  
    10 .. literalinclude:: ../../tw/forms/samples.py 
  • projects/ToscaWidgetsForms/trunk/tw/forms/core.py

    r4429 r4563  
    140140 
    141141    def adjust_value(self,value, validator=None): 
     142        """ 
     143        Adjusts the python value sent to :meth:`InputWidget.display` with 
     144        the validator so it can be rendered in the template. 
     145        """ 
    142146        validator = validator or self.validator 
    143147        if validator and ((not isinstance(self.validator, Schema)) or  
     
    173177 
    174178    def prepare_dict(self, value, kw, adapt=True): 
     179        """ 
     180        Prepares the dict sent to the template with functions to access the 
     181        children's errors if any. 
     182        """ 
    175183        if value is None: 
    176184            value = self.get_default() 
     
    241249 
    242250    def post_init(self, *args, **kw): 
     251        """Takes care of post-initialization of InputWidgets. 
     252 
     253        If the widget has children this method generates a `Schema` to validate 
     254        including the validators from all children once these are all known. 
     255        """ 
    243256        if _has_child_validators(self) and not isinstance(self, WidgetRepeater): 
    244257            if isinstance(self.validator, Schema): 
  • projects/ToscaWidgetsForms/trunk/tw/forms/samples.py

    r4429 r4563  
    109109                alert('The form contains invalid data\n%s'% unicode(d.error)) 
    110110                ) 
     111 
     112class DemoSingleSelect(SingleSelectField): 
     113    options = [ 
     114        "Python", 
     115        "Haskell", 
     116        "Java", 
     117        "Ruby", 
     118        "Erlang", 
     119        "Javascript" 
     120        ] 
     121 
     122class DemoMultipleSelect(MultipleSelectField): 
     123    options = [ 
     124        "Python", 
     125        "Haskell", 
     126        "Java", 
     127        "Ruby", 
     128        "Erlang", 
     129        "Javascript" 
     130        ] 
     131 
     132class DemoCheckBoxList(CheckBoxList): 
     133    options = [ 
     134        "Python", 
     135        "Haskell", 
     136        "Java", 
     137        "Ruby", 
     138        "Erlang", 
     139        "Javascript" 
     140        ] 
     141 
     142class DemoRadioButtonList(RadioButtonList): 
     143    options = [ 
     144        "Python", 
     145        "Haskell", 
     146        "Java", 
     147        "Ruby", 
     148        "Erlang", 
     149        "Javascript" 
     150        ] 
     151 
     152class DemoCheckBoxTable(CheckBoxTable): 
     153    num_cols = 2 
     154    options = [ 
     155        "Python", 
     156        "Haskell", 
     157        "Java", 
     158        "Ruby", 
     159        "Erlang", 
     160        "Javascript" 
     161        ] 
     162 
     163class Person(object): 
     164    def __init__(self, name, age): 
     165        self.__dict__.update(locals()) 
     166 
     167class DemoDataGrid(DataGrid): 
     168    fields = [("Name", "name"), ("Age","age")] 
     169    default = [ 
     170        Person('Lucy', 29), 
     171        Person('Peter', 15), 
     172        Person('Tiffany', 17), 
     173        ]