Mike Orr avatar Mike Orr committed e68c479

More work on unfinished group helper.

Comments (0)

Files changed (1)

unfinished/group.py

-def checkbox_group(name, selected_values, options, ncol, 
-    direction="horizontal"):
+def checkbox_group(name, selected_values, options, nrows=None):
     """Return a group of checkboxes arranged in columns.  See ``group()``.
     """
-    return group(name, selected_values, options, ncol, direction, "checkbox")
+    return group(name, selected_values, options, nrows, "checkbox")
 
-def radio_group(name, selected_values, options, ncol, 
-    direction="horizontal"):
+def radio_group(name, selected_values, options, nrows):
     """Return a group of radio buttons  arranged in columns.  See ``group()``.
     """
-    return group(name, selected_values, options, ncol, direction, "radio")
+    return group(name, selected_values, options, nrows=None, "radio")
 
 
-def group(name, selected_values, options, ncol, direction="horizontal",
-    input_type="checkbox"):
+def group(name, selected_values, options, nrows=None, input_type="checkbox"):
     """Return a group of checkboxes or radio buttons arranged in columns.
 
+    The current implementation puts the widgets in an 
+    ``<ul class="field-group">``, with a ``<div class="field-group-column">``
+    around each column, and a ``<fieldset class="field-group>"`` around the
+    whole thing.  You'll have to set an appropriate style for this
+    class in order to get the column effect; 
+    e.g., "div.field-group-column {float:left, margin-right: 2em}".
+
     Arguments:
 
       ``name`` -- name of the widget group (<input name=>).
       ``options`` -- a list of ``Option`` objects or ``(value, label)``
           pairs.  See ``select()`` for the range of legal values.
 
-      ``ncol`` -- number of columns.
-
-      ``direction`` -- "horizontal" or "vertical" (or any string starting
-          with "h" or "v", case insensitive).  In horizontal groups, the second
-          element is to the right of the first.  In vertical groups, the
-          second element is below it.
+      ``nrows`` -- number of rows (i.e., max number of widgets per column).
 
       ``input_type`` -- "checkbox" or "radio".
     """
         raise ValueError("input type must be 'checkbox' or 'radio'")
     if not isinstance(options, Options):
         options = Options(options)
-    options_html = [
+    html_options = [
         HTML.label(
             HTML.input(type=input_type, name=name, value=x.value),
             x.label)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.