I had to convert a PHP form that has multiselect checkboxes with the same
name, splitting them into two or three columns of approximately equal
size.
Chemistry
...
I made a CheckboxesWidget that's a cross between a RadiobuttonsWidget and
a MultipleSelectWidget, along with a columnizing function and a
columns-to-HTML-table function. If anyone wants them or it would be
appropriate for quixote.widgets, I can make a patch. (Otherwise y'all can
wait till I update my demo. :)
One irritation came up, another htmltext thing. My HTML function looks
like this:
def htmlColumns(lis, delim="
\n"):
"""@param lis A list (each column) of lists (the items in the column).
@param delim Placed between each item in the column.
@return A one-row HTML table without borders.
"""
#lis = [delim.join(columnList) for columnList in lis]
cells = []
for columnList in lis:
columnList = [str(x) for x in columnList]
cell = delim.join(columnList)
cell = htmltext(cell)
cells.append(cell)
table = [cells] # A one-row table.
return htmlTable(table, standard=False, tableAttrs={})
The commented line fails because the columnlist elements are htmltext
rather than str. The for-loop is to get around this. I have to str()
each element and htmltext() the joined column. Is there a shorter way to
do this without being obfuscating?