mirror of
https://github.com/evennia/evennia.git
synced 2026-03-20 06:46:31 +01:00
775 lines
No EOL
65 KiB
HTML
775 lines
No EOL
65 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html lang="en" data-content_root="../">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
|
||
<title>evennia.utils.evtable — Evennia latest documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d75fae25" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=279e0f84" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=e4a91a55" />
|
||
<script src="../_static/documentation_options.js?v=c6e86fd7"></script>
|
||
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
<link rel="icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="evennia.utils.funcparser" href="evennia.utils.funcparser.html" />
|
||
<link rel="prev" title="evennia.utils.evmore" href="evennia.utils.evmore.html" />
|
||
</head><body>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.utils.funcparser.html" title="evennia.utils.funcparser"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.utils.evmore.html" title="evennia.utils.evmore"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.utils.html" accesskey="U">evennia.utils</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.utils.evtable</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.utils.evtable">
|
||
<span id="evennia-utils-evtable"></span><h1>evennia.utils.evtable<a class="headerlink" href="#module-evennia.utils.evtable" title="Link to this heading">¶</a></h1>
|
||
<p>This is an advanced ASCII table creator. It was inspired by Prettytable
|
||
(<a class="reference external" href="https://code.google.com/p/prettytable/">https://code.google.com/p/prettytable/</a>) but shares no code and is considerably
|
||
more advanced, supporting auto-balancing of incomplete tables and ANSI colors among
|
||
other things.</p>
|
||
<p>Example usage:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">evennia.utils</span><span class="w"> </span><span class="kn">import</span> <span class="n">evtable</span>
|
||
|
||
<span class="n">table</span> <span class="o">=</span> <span class="n">evtable</span><span class="o">.</span><span class="n">EvTable</span><span class="p">(</span><span class="s2">"Heading1"</span><span class="p">,</span> <span class="s2">"Heading2"</span><span class="p">,</span>
|
||
<span class="n">table</span><span class="o">=</span><span class="p">[[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">],[</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">,</span><span class="mi">9</span><span class="p">]],</span> <span class="n">border</span><span class="o">=</span><span class="s2">"cells"</span><span class="p">)</span>
|
||
<span class="n">table</span><span class="o">.</span><span class="n">add_column</span><span class="p">(</span><span class="s2">"This is long data"</span><span class="p">,</span> <span class="s2">"This is even longer data"</span><span class="p">)</span>
|
||
<span class="n">table</span><span class="o">.</span><span class="n">add_row</span><span class="p">(</span><span class="s2">"This is a single row"</span><span class="p">)</span>
|
||
<span class="nb">print</span> <span class="n">table</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Result:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">+----------------------+----------+---+--------------------------+</span>
|
||
<span class="o">|</span> <span class="n">Heading1</span> <span class="o">|</span> <span class="n">Heading2</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~+~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~+</span>
|
||
<span class="o">|</span> <span class="mi">1</span> <span class="o">|</span> <span class="mi">4</span> <span class="o">|</span> <span class="mi">7</span> <span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">long</span> <span class="n">data</span> <span class="o">|</span>
|
||
<span class="o">+----------------------+----------+---+--------------------------+</span>
|
||
<span class="o">|</span> <span class="mi">2</span> <span class="o">|</span> <span class="mi">5</span> <span class="o">|</span> <span class="mi">8</span> <span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">even</span> <span class="n">longer</span> <span class="n">data</span> <span class="o">|</span>
|
||
<span class="o">+----------------------+----------+---+--------------------------+</span>
|
||
<span class="o">|</span> <span class="mi">3</span> <span class="o">|</span> <span class="mi">6</span> <span class="o">|</span> <span class="mi">9</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+----------------------+----------+---+--------------------------+</span>
|
||
<span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">a</span> <span class="n">single</span> <span class="n">row</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+----------------------+----------+---+--------------------------+</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>As seen, the table will automatically expand with empty cells to make
|
||
the table symmetric. Tables can be restricted to a given width:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">table</span><span class="o">.</span><span class="n">reformat</span><span class="p">(</span><span class="n">width</span><span class="o">=</span><span class="mi">50</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s2">"l"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(We could just have added these keywords to the table creation call)</p>
|
||
<p>This yields the following result:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">+-----------+------------+-----------+-----------+</span>
|
||
<span class="o">|</span> <span class="n">Heading1</span> <span class="o">|</span> <span class="n">Heading2</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+~~~~~~~~~~~+~~~~~~~~~~~~+~~~~~~~~~~~+~~~~~~~~~~~+</span>
|
||
<span class="o">|</span> <span class="mi">1</span> <span class="o">|</span> <span class="mi">4</span> <span class="o">|</span> <span class="mi">7</span> <span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="n">long</span> <span class="n">data</span> <span class="o">|</span>
|
||
<span class="o">+-----------+------------+-----------+-----------+</span>
|
||
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="mi">2</span> <span class="o">|</span> <span class="mi">5</span> <span class="o">|</span> <span class="mi">8</span> <span class="o">|</span> <span class="n">even</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="n">longer</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="n">data</span> <span class="o">|</span>
|
||
<span class="o">+-----------+------------+-----------+-----------+</span>
|
||
<span class="o">|</span> <span class="mi">3</span> <span class="o">|</span> <span class="mi">6</span> <span class="o">|</span> <span class="mi">9</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+-----------+------------+-----------+-----------+</span>
|
||
<span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">a</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="n">single</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="n">row</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+-----------+------------+-----------+-----------+</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Table-columns can be individually formatted. Note that if an
|
||
individual column is set with a specific width, table auto-balancing
|
||
will not affect this column (this may lead to the full table being too
|
||
wide, so be careful mixing fixed-width columns with auto- balancing).
|
||
Here we change the width and alignment of the column at index 3
|
||
(Python starts from 0):</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">table</span><span class="o">.</span><span class="n">reformat_column</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s2">"r"</span><span class="p">)</span>
|
||
<span class="nb">print</span> <span class="n">table</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">+-----------+-------+-----+-----------------------------+---------+</span>
|
||
<span class="o">|</span> <span class="n">Heading1</span> <span class="o">|</span> <span class="n">Headi</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="o">|</span> <span class="n">ng2</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+~~~~~~~~~~~+~~~~~~~+~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~+</span>
|
||
<span class="o">|</span> <span class="mi">1</span> <span class="o">|</span> <span class="mi">4</span> <span class="o">|</span> <span class="mi">7</span> <span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">long</span> <span class="n">data</span> <span class="o">|</span> <span class="n">Test1</span> <span class="o">|</span>
|
||
<span class="o">+-----------+-------+-----+-----------------------------+---------+</span>
|
||
<span class="o">|</span> <span class="mi">2</span> <span class="o">|</span> <span class="mi">5</span> <span class="o">|</span> <span class="mi">8</span> <span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">even</span> <span class="n">longer</span> <span class="n">data</span> <span class="o">|</span> <span class="n">Test3</span> <span class="o">|</span>
|
||
<span class="o">+-----------+-------+-----+-----------------------------+---------+</span>
|
||
<span class="o">|</span> <span class="mi">3</span> <span class="o">|</span> <span class="mi">6</span> <span class="o">|</span> <span class="mi">9</span> <span class="o">|</span> <span class="o">|</span> <span class="n">Test4</span> <span class="o">|</span>
|
||
<span class="o">+-----------+-------+-----+-----------------------------+---------+</span>
|
||
<span class="o">|</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">a</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="n">single</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">|</span> <span class="n">row</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||
<span class="o">+-----------+-------+-----+-----------------------------+---------+</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>When adding new rows/columns their data can have its own alignments
|
||
(left/center/right, top/center/bottom).</p>
|
||
<p>If the height is restricted, cells will be restricted from expanding
|
||
vertically. This will lead to text contents being cropped. Each cell
|
||
can only shrink to a minimum width and height of 1.</p>
|
||
<p><strong>EvTable</strong> is intended to be used with <strong>ANSIString</strong> for supporting ANSI-coloured
|
||
string types.</p>
|
||
<p>When a cell is auto-wrapped across multiple lines, ANSI-reset sequences will be
|
||
put at the end of each wrapped line. This means that the colour of a wrapped
|
||
cell will not “bleed”, but it also means that eventual colour outside the table
|
||
will not transfer “across” a table, you need to re-set the color to have it
|
||
appear on both sides of the table string.</p>
|
||
<hr class="docutils" />
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.ANSITextWrapper">
|
||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">evennia.utils.evtable.</span></span><span class="sig-name descname"><span class="pre">ANSITextWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">70</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">initial_indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subsequent_indent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expand_tabs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">replace_whitespace</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fix_sentence_endings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">break_long_words</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">drop_whitespace</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">break_on_hyphens</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tabsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">8</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_lines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">placeholder</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'</span> <span class="pre">[...]'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#ANSITextWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.ANSITextWrapper" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">TextWrapper</span></code></p>
|
||
<p>This is a wrapper work class for handling strings with ANSI tags
|
||
in it. It overloads the standard library <strong>TextWrapper</strong> class and
|
||
is used internally in <strong>EvTable</strong> and has no public methods.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.wrap">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.utils.evtable.</span></span><span class="sig-name descname"><span class="pre">wrap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">78</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#wrap"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.wrap" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Wrap a single paragraph of text, returning a list of wrapped lines.</p>
|
||
<p>Reformat the single paragraph in ‘text’ so it fits in lines of no
|
||
more than ‘width’ columns, and return a list of wrapped lines. By
|
||
default, tabs in ‘text’ are expanded with string.expandtabs(), and
|
||
all other whitespace characters (including newline) are converted to</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>text</strong> (<em>str</em>) – Text to wrap.</p></li>
|
||
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – Width to wrap <strong>text</strong> to.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>customize</strong> (<em>See TextWrapper class for available keyword args to</em>)</p></li>
|
||
<li><p><strong>behaviour.</strong> (<em>wrapping</em>)</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.fill">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.utils.evtable.</span></span><span class="sig-name descname"><span class="pre">fill</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">78</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#fill"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.fill" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Fill a single paragraph of text, returning a new string.</p>
|
||
<p>Reformat the single paragraph in ‘text’ to fit in lines of no more
|
||
than ‘width’ columns, and return a new string containing the entire
|
||
wrapped paragraph. As with wrap(), tabs are expanded and other
|
||
whitespace characters converted to space.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>text</strong> (<em>str</em>) – Text to fill.</p></li>
|
||
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – Width of fill area.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>customize</strong> (<em>See TextWrapper class for available keyword args to</em>)</p></li>
|
||
<li><p><strong>behaviour.</strong> (<em>filling</em>)</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell">
|
||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">evennia.utils.evtable.</span></span><span class="sig-name descname"><span class="pre">EvCell</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>Holds a single data cell for the table. A cell has a certain width
|
||
and height and contains one or more lines of data. It can shrink
|
||
and resize as needed.</p>
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.__init__">
|
||
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.__init__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.__init__" title="Link to this definition">¶</a></dt>
|
||
<dd><dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>data</strong> (<em>str</em>) – The un-padded data of the entry.</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>width</strong> (<em>int</em>) – Desired width of cell. It will pad
|
||
to this size.</p></li>
|
||
<li><p><strong>height</strong> (<em>int</em>) – Desired height of cell. it will pad
|
||
to this size.</p></li>
|
||
<li><p><strong>pad_width</strong> (<em>int</em>) – General padding width. This can be overruled
|
||
by individual settings below.</p></li>
|
||
<li><p><strong>pad_left</strong> (<em>int</em>) – Number of extra pad characters on the left.</p></li>
|
||
<li><p><strong>pad_right</strong> (<em>int</em>) – Number of extra pad characters on the right.</p></li>
|
||
<li><p><strong>pad_top</strong> (<em>int</em>) – Number of extra pad lines top (will pad with <strong>vpad_char</strong>).</p></li>
|
||
<li><p><strong>pad_bottom</strong> (<em>int</em>) – Number of extra pad lines bottom (will pad with <strong>vpad_char</strong>).</p></li>
|
||
<li><p><strong>pad_char</strong> (<em>str</em>) – by individual settings below (default <strong>“ “</strong>).</p></li>
|
||
<li><p><strong>hpad_char</strong> (<em>str</em>) – Pad character to use both for extra horizontal
|
||
padding (default <strong>“ “</strong>).</p></li>
|
||
<li><p><strong>vpad_char</strong> (<em>str</em>) – Pad character to use for extra vertical padding
|
||
and for vertical fill (default <strong>“ “</strong>).</p></li>
|
||
<li><p><strong>fill_char</strong> (<em>str</em>) – Character used to filling (expanding cells to
|
||
desired size). This can be overruled by individual settings below.</p></li>
|
||
<li><p><strong>hfill_char</strong> (<em>str</em>) – Character used for horizontal fill (default <strong>“ “</strong>).</p></li>
|
||
<li><p><strong>vfill_char</strong> (<em>str</em>) – Character used for vertical fill (default <strong>“ “</strong>).</p></li>
|
||
<li><p><strong>align</strong> (<em>str</em>) – Should be one of “l”, “r”, “c”, “f” or “a” for left-, right-, center-,
|
||
full-justified (with space between words) or absolute (keep as much original
|
||
whitespace as possible). Default is left-aligned.</p></li>
|
||
<li><p><strong>valign</strong> (<em>str</em>) – Should be one of “t”, “b” or “c” for top-, bottom and center
|
||
vertical alignment respectively. Default is centered.</p></li>
|
||
<li><p><strong>border_width</strong> (<em>int</em>) – General border width. This is overruled
|
||
by individual settings below.</p></li>
|
||
<li><p><strong>border_left</strong> (<em>int</em>) – Left border width.</p></li>
|
||
<li><p><strong>border_right</strong> (<em>int</em>) – Right border width.</p></li>
|
||
<li><p><strong>border_top</strong> (<em>int</em>) – Top border width.</p></li>
|
||
<li><p><strong>border_bottom</strong> (<em>int</em>) – Bottom border width.</p></li>
|
||
<li><p><strong>border_char</strong> (<em>str</em>) – This will use a single border char for all borders.
|
||
overruled by individual settings below.</p></li>
|
||
<li><p><strong>border_left_char</strong> (<em>str</em>) – Char used for left border.</p></li>
|
||
<li><p><strong>border_right_char</strong> (<em>str</em>) – Char used for right border.</p></li>
|
||
<li><p><strong>border_top_char</strong> (<em>str</em>) – Char used for top border.</p></li>
|
||
<li><p><strong>border_bottom_char</strong> (<em>str</em>) – Char user for bottom border.</p></li>
|
||
<li><p><strong>corner_char</strong> (<em>str</em>) – Character used when two borders cross. (default is “”).
|
||
This is overruled by individual settings below.</p></li>
|
||
<li><p><strong>corner_top_left_char</strong> (<em>str</em>) – Char used for “nw” corner.</p></li>
|
||
<li><p><strong>corner_top_right_char</strong> (<em>str</em>) – Char used for “ne” corner.</p></li>
|
||
<li><p><strong>corner_bottom_left_char</strong> (<em>str</em>) – Char used for “sw” corner.</p></li>
|
||
<li><p><strong>corner_bottom_right_char</strong> (<em>str</em>) – Char used for “se” corner.</p></li>
|
||
<li><p><strong>crop_string</strong> (<em>str</em>) – String to use when cropping sideways, default is <strong>‘[…]’</strong>.</p></li>
|
||
<li><p><strong>crop</strong> (<em>bool</em>) – Crop contentof cell rather than expand vertically, default=**False**.</p></li>
|
||
<li><p><strong>enforce_size</strong> (<em>bool</em>) – If true, the width/height of the cell is
|
||
strictly enforced and extra text will be cropped rather than the
|
||
cell growing vertically.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-odd">Raises<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>Exception</strong> – for impossible cell size requirements where the
|
||
border width or height cannot fit, or the content is too
|
||
small.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.get_min_height">
|
||
<span class="sig-name descname"><span class="pre">get_min_height</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.get_min_height"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.get_min_height" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Get the minimum possible height of cell, including at least
|
||
one line for data.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><em>min_height (int)</em> – The mininum height of cell.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.get_min_width">
|
||
<span class="sig-name descname"><span class="pre">get_min_width</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.get_min_width"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.get_min_width" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Get the minimum possible width of cell, including at least one
|
||
character-width for data.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><em>min_width (int)</em> – The minimum width of cell.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.get_height">
|
||
<span class="sig-name descname"><span class="pre">get_height</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.get_height"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.get_height" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Get natural height of cell, including padding.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><em>natural_height (int)</em> – Height of cell.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.get_width">
|
||
<span class="sig-name descname"><span class="pre">get_width</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.get_width"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.get_width" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Get natural width of cell, including padding.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><em>natural_width (int)</em> – Width of cell.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.replace_data">
|
||
<span class="sig-name descname"><span class="pre">replace_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.replace_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.replace_data" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Replace cell data. This causes a full reformat of the cell.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>data</strong> (<em>str</em>) – Cell data.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>The available keyword arguments are the same as for
|
||
<strong>EvCell.__init__</strong>.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.reformat">
|
||
<span class="sig-name descname"><span class="pre">reformat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.reformat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.reformat" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Reformat the EvCell with new options</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>EvCell.__init__.</strong> (<em>The available keyword arguments are the same as for</em>)</p>
|
||
</dd>
|
||
<dt class="field-even">Raises<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>Exception</strong> – If the cells cannot shrink enough to accomodate
|
||
the options or the data given.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvCell.get">
|
||
<span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvCell.get"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvCell.get" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Get data, padded and aligned in the form of a list of lines.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvColumn">
|
||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">evennia.utils.evtable.</span></span><span class="sig-name descname"><span class="pre">EvColumn</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvColumn"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvColumn" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>This class holds a list of Cells to represent a column of a table.
|
||
It holds operations and settings that affect <em>all</em> cells in the
|
||
column.</p>
|
||
<p>Columns are not intended to be used stand-alone; they should be
|
||
incorporated into an EvTable (like EvCells)</p>
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvColumn.__init__">
|
||
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvColumn.__init__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvColumn.__init__" title="Link to this definition">¶</a></dt>
|
||
<dd><dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>column</strong> (<em>Text for each row in the</em>)</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>these</strong> (<em>All EvCell.__init_ keywords are available</em><em>,</em>)</p></li>
|
||
<li><p><strong>the</strong> (<em>settings will be persistently applied to every Cell in</em>)</p></li>
|
||
<li><p><strong>column.</strong></p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvColumn.add_rows">
|
||
<span class="sig-name descname"><span class="pre">add_rows</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvColumn.add_rows"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvColumn.add_rows" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Add new cells to column. They will be inserted as
|
||
a series of rows. It will inherit the options
|
||
of the rest of the column’s cells (use update to change
|
||
options).</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>cells</strong> (<em>Texts for the new</em>)</p></li>
|
||
<li><p><strong>ypos</strong> (<em>int</em><em>, </em><em>optional</em>) – Index position in table before which to insert the
|
||
new column. Uses Python indexing, so to insert at the top,
|
||
use <strong>ypos=0</strong>. If not given, data will be inserted at the end
|
||
of the column.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>EvCell.__init__.</strong> (<em>Available keywods as per</em>)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvColumn.reformat">
|
||
<span class="sig-name descname"><span class="pre">reformat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvColumn.reformat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvColumn.reformat" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Change the options for the column.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>EvCell.__init__.</strong> (<em>Keywords as per</em>)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvColumn.reformat_cell">
|
||
<span class="sig-name descname"><span class="pre">reformat_cell</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvColumn.reformat_cell"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvColumn.reformat_cell" title="Link to this definition">¶</a></dt>
|
||
<dd><p>reformat cell at given index, keeping column options if
|
||
necessary.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>index</strong> (<em>int</em>) – Index location of the cell in the column,
|
||
starting from 0 for the first row to Nrows-1.</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>EvCell.__init__.</strong> (<em>Keywords as per</em>)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable">
|
||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">evennia.utils.evtable.</span></span><span class="sig-name descname"><span class="pre">EvTable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>The table class holds a list of EvColumns, each consisting of EvCells so
|
||
that the result is a 2D matrix.</p>
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.__init__">
|
||
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.__init__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.__init__" title="Link to this definition">¶</a></dt>
|
||
<dd><dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>table.</strong> (<em>Header texts for the</em>)</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>table</strong> (list of lists or list of <strong>EvColumns</strong>, optional) – This is used to build the table in a quick way. If not
|
||
given, the table will start out empty and <strong>add_</strong> methods
|
||
need to be used to add rows/columns.</p></li>
|
||
<li><p><strong>header</strong> (<em>bool</em><em>, </em><em>optional</em>) – <strong>True</strong>/<strong>False</strong> - turn off the
|
||
header texts (<strong>*args</strong>) being treated as a header (such as
|
||
not adding extra underlining)</p></li>
|
||
<li><p><strong>pad_width</strong> (<em>int</em><em>, </em><em>optional</em>) – How much empty space to pad your cells with
|
||
(default is 1)</p></li>
|
||
<li><p><strong>border</strong> (<em>str</em><em>, </em><em>optional</em><em>)</em>) – The border style to use. This is one of
|
||
- <strong>None</strong> - No border drawing at all.
|
||
- “table” - only a border around the whole table.
|
||
- “tablecols” - table and column borders. (default)
|
||
- “header” - only border under header.
|
||
- “cols” - only vertical borders.
|
||
- “incols” - vertical borders, no outer edges.
|
||
- “rows” - only borders between rows.
|
||
- “cells” - border around all cells.</p></li>
|
||
<li><p><strong>border_width</strong> (<em>int</em><em>, </em><em>optional</em>) – Width of table borders, if border is active.
|
||
Note that widths wider than 1 may give artifacts in the corners. Default is 1.</p></li>
|
||
<li><p><strong>corner_char</strong> (<em>str</em><em>, </em><em>optional</em>) – Character to use in corners when border is active.
|
||
Default is <strong>+</strong>.</p></li>
|
||
<li><p><strong>corner_top_left_char</strong> (<em>str</em><em>, </em><em>optional</em>) – Character used for “nw” corner of table.
|
||
Defaults to <strong>corner_char</strong>.</p></li>
|
||
<li><p><strong>corner_top_right_char</strong> (<em>str</em><em>, </em><em>optional</em>) – Character used for “ne” corner of table.
|
||
Defaults to <strong>corner_char</strong>.</p></li>
|
||
<li><p><strong>corner_bottom_left_char</strong> (<em>str</em><em>, </em><em>optional</em>) – Character used for “sw” corner of table.
|
||
Defaults to <strong>corner_char</strong>.</p></li>
|
||
<li><p><strong>corner_bottom_right_char</strong> (<em>str</em><em>, </em><em>optional</em>) – Character used for “se” corner of table.
|
||
Defaults to <strong>corner_char</strong>.</p></li>
|
||
<li><p><strong>pretty_corners</strong> (<em>bool</em><em>, </em><em>optional</em>) – Use custom characters to
|
||
make the table corners look “rounded”. Uses UTF-8
|
||
characters. Defaults to <strong>False</strong> for maximum compatibility with various displays
|
||
that may occationally have issues with UTF-8 characters.</p></li>
|
||
<li><p><strong>header_line_char</strong> (<em>str</em><em>, </em><em>optional</em>) – Character to use for underlining
|
||
the header row (default is ‘~’). Requires <strong>border</strong> to not be <strong>None</strong>.</p></li>
|
||
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – Fixed width of table. If not set,
|
||
width is set by the total width of each column. This will
|
||
resize individual columns in the vertical direction to fit.</p></li>
|
||
<li><p><strong>height</strong> (<em>int</em><em>, </em><em>optional</em>) – Fixed height of table. Defaults to being unset. Width is
|
||
still given precedence. If given, table cells will crop text rather
|
||
than expand vertically.</p></li>
|
||
<li><p><strong>evenwidth</strong> (<em>bool</em><em>, </em><em>optional</em>) – Used with the <strong>width</strong> keyword. Adjusts columns to have as
|
||
even width as possible. This often looks best also for mixed-length tables. Default
|
||
is <strong>False</strong>.</p></li>
|
||
<li><p><strong>maxwidth</strong> (<em>int</em><em>, </em><em>optional</em>) – This will set a maximum width
|
||
of the table while allowing it to be smaller. Only if it grows wider than this
|
||
size will it be resized by expanding horizontally (or crop <strong>height</strong> is given).
|
||
This keyword has no meaning if <strong>width</strong> is set.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-odd">Raises<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>Exception</strong> – If given erroneous input or width settings for the data.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>Beyond those table-specific keywords, the non-overlapping keywords
|
||
of <strong>EvCell.__init__</strong> are also available. These will be passed down
|
||
to every cell in the table.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.add_header">
|
||
<span class="sig-name descname"><span class="pre">add_header</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.add_header"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.add_header" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Add header to table. This is a number of texts to be put at
|
||
the top of the table. They will replace an existing header.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>args</strong> (<em>str</em>) – These strings will be used as the header texts.</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>applied</strong> (<em>Same keywords as per EvTable.__init__. Will be</em>)</p></li>
|
||
<li><p><strong>cells.</strong> (<em>to the new header's</em>)</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.add_column">
|
||
<span class="sig-name descname"><span class="pre">add_column</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.add_column"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.add_column" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Add a column to table. If there are more rows in new column
|
||
than there are rows in the current table, the table will
|
||
expand with empty rows in the other columns. If too few, the
|
||
new column with get new empty rows. All filling rows are added
|
||
to the end.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>args</strong> (<strong>EvColumn</strong> or multiple strings) – Either a single EvColumn instance or
|
||
a number of data string arguments to be used to create a new column.</p></li>
|
||
<li><p><strong>header</strong> (<em>str</em><em>, </em><em>optional</em>) – The header text for the column</p></li>
|
||
<li><p><strong>xpos</strong> (<em>int</em><em>, </em><em>optional</em>) – Index position in table <em>before</em> which
|
||
to input new column. If not given, column will be added to the end
|
||
of the table. Uses Python indexing (so first column is <strong>xpos=0</strong>)</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>Cell.__init__.</strong> (<em>Other keywords as per</em>)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.add_row">
|
||
<span class="sig-name descname"><span class="pre">add_row</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.add_row"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.add_row" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Add a row to table (not a header). If there are more cells in
|
||
the given row than there are cells in the current table the
|
||
table will be expanded with empty columns to match. These will
|
||
be added to the end of the table. In the same way, adding a
|
||
line with too few cells will lead to the last ones getting
|
||
padded.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>args</strong> (<em>str</em>) – Any number of string argumnets to use as the
|
||
data in the row (one cell per argument).</p></li>
|
||
<li><p><strong>ypos</strong> (<em>int</em><em>, </em><em>optional</em>) – Index position in table before which to
|
||
input new row. If not given, will be added to the end of the table.
|
||
Uses Python indexing (so first row is <strong>ypos=0</strong>)</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>EvCell.__init__.</strong> (<em>Other keywords are as per</em>)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.reformat">
|
||
<span class="sig-name descname"><span class="pre">reformat</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.reformat"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.reformat" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Force a re-shape of the entire table.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>EvTable.__init__.</strong> (<em>Table options as per</em>)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.reformat_column">
|
||
<span class="sig-name descname"><span class="pre">reformat_column</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.reformat_column"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.reformat_column" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Sends custom options to a specific column in the table.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>index</strong> (<em>int</em>) – Which column to reformat. The column index is
|
||
given from 0 to Ncolumns-1.</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><strong>EvCell.__init__.</strong> (<em>Column options as per</em>)</p>
|
||
</dd>
|
||
<dt class="field-odd">Raises<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>Exception</strong> – if an invalid index is found.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.utils.evtable.EvTable.get">
|
||
<span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/utils/evtable.html#EvTable.get"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.utils.evtable.EvTable.get" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Return lines of table as a list.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><em>table_lines (list)</em> – The lines of the table, in order.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo of Evennia"/>
|
||
</a></p>
|
||
<search id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</search>
|
||
<script>document.getElementById('searchbox').style.display = "block"</script>
|
||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">evennia.utils.evtable</a><ul>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.ANSITextWrapper"><code class="docutils literal notranslate"><span class="pre">ANSITextWrapper</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.wrap"><code class="docutils literal notranslate"><span class="pre">wrap()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.fill"><code class="docutils literal notranslate"><span class="pre">fill()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell"><code class="docutils literal notranslate"><span class="pre">EvCell</span></code></a><ul>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.__init__"><code class="docutils literal notranslate"><span class="pre">EvCell.__init__()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.get_min_height"><code class="docutils literal notranslate"><span class="pre">EvCell.get_min_height()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.get_min_width"><code class="docutils literal notranslate"><span class="pre">EvCell.get_min_width()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.get_height"><code class="docutils literal notranslate"><span class="pre">EvCell.get_height()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.get_width"><code class="docutils literal notranslate"><span class="pre">EvCell.get_width()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.replace_data"><code class="docutils literal notranslate"><span class="pre">EvCell.replace_data()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.reformat"><code class="docutils literal notranslate"><span class="pre">EvCell.reformat()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvCell.get"><code class="docutils literal notranslate"><span class="pre">EvCell.get()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvColumn"><code class="docutils literal notranslate"><span class="pre">EvColumn</span></code></a><ul>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvColumn.__init__"><code class="docutils literal notranslate"><span class="pre">EvColumn.__init__()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvColumn.add_rows"><code class="docutils literal notranslate"><span class="pre">EvColumn.add_rows()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvColumn.reformat"><code class="docutils literal notranslate"><span class="pre">EvColumn.reformat()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvColumn.reformat_cell"><code class="docutils literal notranslate"><span class="pre">EvColumn.reformat_cell()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable"><code class="docutils literal notranslate"><span class="pre">EvTable</span></code></a><ul>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.__init__"><code class="docutils literal notranslate"><span class="pre">EvTable.__init__()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.add_header"><code class="docutils literal notranslate"><span class="pre">EvTable.add_header()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.add_column"><code class="docutils literal notranslate"><span class="pre">EvTable.add_column()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.add_row"><code class="docutils literal notranslate"><span class="pre">EvTable.add_row()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.reformat"><code class="docutils literal notranslate"><span class="pre">EvTable.reformat()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.reformat_column"><code class="docutils literal notranslate"><span class="pre">EvTable.reformat_column()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.utils.evtable.EvTable.get"><code class="docutils literal notranslate"><span class="pre">EvTable.get()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.utils.evmore.html"
|
||
title="previous chapter">evennia.utils.evmore</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.utils.funcparser.html"
|
||
title="next chapter">evennia.utils.funcparser</a></p>
|
||
</div>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.utils.evtable.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
<h3>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/latest/index.html">latest (main branch)</a>
|
||
</li>
|
||
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/5.x/index.html">v5.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/4.x/index.html">v4.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/3.x/index.html">v3.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/2.x/index.html">v2.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/1.x/index.html">v1.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/0.x/index.html">v0.9.5 branch (outdated)</a>
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.utils.funcparser.html" title="evennia.utils.funcparser"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.utils.evmore.html" title="evennia.utils.evmore"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.utils.html" >evennia.utils</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.utils.evtable</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2024, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
||
</div>
|
||
</body>
|
||
</html> |