Previous Next blank.gif blank.gif

Class List - Will generate a bulleted list given a list argument.


SYNOPSIS

import HTMLgen
class List(UserList)
  int I_am_a_list = 1
  def __getslice__(self, i, j)
  def __init__(self, list = None, **kw)
  string __module__ = 'HTMLgen'
  def __str__(self)
  def append(self, *items)
  tuple attrs = ('type', 'align', 'class', ...
  string attr_template = ''
  def column_slices(self, columns=1)
  int I_am_a_list = 1
  def end_element(self)
  tuple flags = ('compact',)
  int I_am_a_list = 1
  def multi_column_table(self)
  string pad = '    '
  def render_list_item(self, item)
  def start_element(self)
  def sub_list(self, list)
  string tagname = 'UL'

  # Methods inherited by List from UserList
  def __add__(self, list)
  def __cmp__(self, list)
  def __delitem__(self, i)
  def __delslice__(self, i, j)
  def __getitem__(self, i)
  def __len__(self)
  def __mul__(self, n)
  def __mul__(self, n)
  def __radd__(self, list)
  def __repr__(self)
  def __setitem__(self, i, item)
  def __setslice__(self, i, j, list)
  def count(self, item)
  def index(self, item)
  def insert(self, i, item)
  def pop(self, i=-1)
  def remove(self, item)
  def reverse(self)
  def sort(self, *args)
alias BulletList = List
alias UL = List

DESCRIPTION

Now supports rendering a list into multiple columns by setting the columns attribute to a number greater than one. This is implemented using tables and you can also set a background color for the list itself by using the bgcolor attribute.

Supports nested lists, i.e. lists of lists. Each time a list is encountered in a list it will indent those contents w.r.t. the prior list entry. This can continue indefinitely through nested lists although there are only three different bullets provided by the browser (typically).

Optional keyword indent can be used to indicate whether you want the list to start left justified or indented. indent=0 will make it left justified. The default is to indent.

Optional keyword type can be set to either disk, circle, or square to specify what kind of symbol is used for each list item's bullet. (Netscape extension)

Since we inherit from the UserList class any normal list operations work on instances of this class. Any list contents will do. Each of the items will be emitted in html if they are themselves objects from this module. Aliases: UL, BulletList

def append(self, *items)

Append entries to the end of the list

def column_slices(self, columns=1)

Calculate a list of index pairs bounding column slices.

def end_element(self)

Closes the HTML element

def multi_column_table(self)

Return a table containing the list sliced into columns.

def render_list_item(self, item)

Renders the individual list items

Overloaded by child classes to represent other list styles.

def start_element(self)

Generic creator for the HTML element opening tag.

Reads tagname, attrs and flags to return appropriate tag.

def sub_list(self, list)

Recursive method for generating a subordinate list

SEE ALSO

HTMLgen

UserList


Previous Next blank.gif blank.gif
Buzz.gif

Copyright © Robin Friedrich
All Rights Reserved
Comments to author: friedrich@pythonpros.com
Generated: Tue Apr 20, 1999