⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writer-interface.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>12.1.3 The Writer Interface </title>
<META NAME="description" CONTENT="12.1.3 The Writer Interface ">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html">
<LINK REL="previous" href="formatter-impls.html" tppabs="http://www.python.org/doc/current/lib/formatter-impls.html">
<LINK REL="up" href="module-formatter.html" tppabs="http://www.python.org/doc/current/lib/module-formatter.html">
<LINK REL="next" href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="formatter-impls.html" tppabs="http://www.python.org/doc/current/lib/formatter-impls.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-formatter.html" tppabs="http://www.python.org/doc/current/lib/module-formatter.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="formatter-impls.html" tppabs="http://www.python.org/doc/current/lib/formatter-impls.html">12.1.2 Formatter Implementations</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-formatter.html" tppabs="http://www.python.org/doc/current/lib/module-formatter.html">12.1 formatter  </A>
<b class="navlabel">Next:</b> <a class="sectref" href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html">12.1.4 Writer Implementations</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H2>
<BR>
12.1.3 The Writer Interface 
</H2>

<P>
Interfaces to create writers are dependent on the specific writer
class being instantiated.  The interfaces described below are the
required interfaces which all writers must support once initialized.
Note that while most applications can use the
<tt class="class">AbstractFormatter</tt> class as a formatter, the writer must
typically be provided by the application.

<P>
<dl><dt><b><a name='l2h-2330'><tt class='method'>flush</tt></a></b> ()
<dd>
Flush any buffered output or device control events.
</dl>

<P>
<dl><dt><b><a name='l2h-2331'><tt class='method'>new_alignment</tt></a></b> (<var>align</var>)
<dd>
Set the alignment style.  The <var>align</var> value can be any object,
but by convention is a string or <code>None</code>, where <code>None</code>
indicates that the writer's ``preferred'' alignment should be used.
Conventional <var>align</var> values are <code>'left'</code>, <code>'center'</code>,
<code>'right'</code>, and <code>'justify'</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-2332'><tt class='method'>new_font</tt></a></b> (<var>font</var>)
<dd>
Set the font style.  The value of <var>font</var> will be <code>None</code>,
indicating that the device's default font should be used, or a tuple
of the form <code>(</code><var>size</var>, <var>italic</var>, <var>bold</var>,
<var>teletype</var><code>)</code>.  Size will be a string indicating the size of
font that should be used; specific strings and their interpretation
must be defined by the application.  The <var>italic</var>, <var>bold</var>, and
<var>teletype</var> values are boolean indicators specifying which of those
font attributes should be used.
</dl>

<P>
<dl><dt><b><a name='l2h-2333'><tt class='method'>new_margin</tt></a></b> (<var>margin, level</var>)
<dd>
Set the margin level to the integer <var>level</var> and the logical tag
to <var>margin</var>.  Interpretation of the logical tag is at the
writer's discretion; the only restriction on the value of the logical
tag is that it not be a false value for non-zero values of
<var>level</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-2334'><tt class='method'>new_spacing</tt></a></b> (<var>spacing</var>)
<dd>
Set the spacing style to <var>spacing</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-2335'><tt class='method'>new_styles</tt></a></b> (<var>styles</var>)
<dd>
Set additional styles.  The <var>styles</var> value is a tuple of
arbitrary values; the value <tt class="constant">AS_IS</tt> should be ignored.  The
<var>styles</var> tuple may be interpreted either as a set or as a stack
depending on the requirements of the application and writer
implementation.
</dl>

<P>
<dl><dt><b><a name='l2h-2336'><tt class='method'>send_line_break</tt></a></b> ()
<dd>
Break the current line.
</dl>

<P>
<dl><dt><b><a name='l2h-2337'><tt class='method'>send_paragraph</tt></a></b> (<var>blankline</var>)
<dd>
Produce a paragraph separation of at least <var>blankline</var> blank
lines, or the equivalent.  The <var>blankline</var> value will be an
integer.  Note that the implementation will receive a call to
<tt class="method">send_line_break()</tt> before this call if a line break is needed; 
this method should not include ending the last line of the paragraph.
It is only responsible for vertical spacing between paragraphs.
</dl>

<P>
<dl><dt><b><a name='l2h-2338'><tt class='method'>send_hor_rule</tt></a></b> (<var>*args, **kw</var>)
<dd>
Display a horizontal rule on the output device.  The arguments to this
method are entirely application- and writer-specific, and should be
interpreted with care.  The method implementation may assume that a
line break has already been issued via <tt class="method">send_line_break()</tt>.
</dl>

<P>
<dl><dt><b><a name='l2h-2339'><tt class='method'>send_flowing_data</tt></a></b> (<var>data</var>)
<dd>
Output character data which may be word-wrapped and re-flowed as
needed.  Within any sequence of calls to this method, the writer may
assume that spans of multiple whitespace characters have been
collapsed to single space characters.
</dl>

<P>
<dl><dt><b><a name='l2h-2340'><tt class='method'>send_literal_data</tt></a></b> (<var>data</var>)
<dd>
Output character data which has already been formatted
for display.  Generally, this should be interpreted to mean that line
breaks indicated by newline characters should be preserved and no new
line breaks should be introduced.  The data may contain embedded
newline and tab characters, unlike data provided to the
<tt class="method">send_formatted_data()</tt> interface.
</dl>

<P>
<dl><dt><b><a name='l2h-2341'><tt class='method'>send_label_data</tt></a></b> (<var>data</var>)
<dd>
Set <var>data</var> to the left of the current left margin, if possible.
The value of <var>data</var> is not restricted; treatment of non-string
values is entirely application- and writer-dependent.  This method
will only be called at the beginning of a line.
</dl>

<P>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="formatter-impls.html" tppabs="http://www.python.org/doc/current/lib/formatter-impls.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-formatter.html" tppabs="http://www.python.org/doc/current/lib/module-formatter.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="formatter-impls.html" tppabs="http://www.python.org/doc/current/lib/formatter-impls.html">12.1.2 Formatter Implementations</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-formatter.html" tppabs="http://www.python.org/doc/current/lib/module-formatter.html">12.1 formatter  </A>
<b class="navlabel">Next:</b> <a class="sectref" href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html">12.1.4 Writer Implementations</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -