A Viewer object is an instance of the
Viewer class, defined in the Viewer module.
A Viewer can display formatted text using a variety of
fonts and styles. This is accomplished mostly through the power of
the Tk text widget, but a Viewer has a particular
interface that better matches the requirements of formatted HTML
display.
The Viewer interface is used by two types of
extensions: HTML extensions and file type extensions. Both have
roughly the same needs (displaying the output of a parser), so this
interface description applies to both cases. It is important that the
Viewer interface is only used while a parser is active;
once the parser has been closed, the viewer should not be touched.
Viewer object has two data attributes that are relevant
to parsers:
viewer.text
add_subwindow() method.
viewer.browser
Browser object containing the viewer, if any.
This variable may be set to None. See the Browser Object Interface.
Viewer object has several methods that are relevant to
parsers. These all either insert data, which may be a text string or
a subwindow, into the text stream, or change settings that affect the
way subsequent elements are formatted.
viewer.new_font((fonttag, italic,
bold, tt))
fontag
argument is either the empty string or a header tag in
lowercase, i.e.. 'h1', 'h2', ...,
'h6'. The italic,
bold and tt
arguments are boolean flags specifying whether the font should
be modified to be italic, bold and/or teletype (fixed width).
viewer.new_margin(margin, level)
margin argument is the tag name in
lowercase that caused the call (e.g. 'blockquote', 'ul', 'ol'
etc.), and level is the accumulated
nesting level (an integer). The first level is
1.
viewer.new_spacing(spacing)
viewer.new_styles(style_tuple)
viewer.send_paragraph(blankline)
blankline is
nonzero, a blank line is inserted after the paragraph.
viewer.send_line_break()
viewer.send_hor_rule()
abswidth
percentwidth
abswidth is
not specified.
height
1 will be enforced.
align
'left', 'center', or
'right'. If this argument is omitted, the
rule is left aligned.
viewer.send_label_data(data)
viewer.send_flowing_data(data)
viewer.send_literal_data(data)
viewer.add_subwindow(widget)
viewer.text widget as its parent.