add tui module and example, add contex manager cd and the method run_file in helper

import vendor modules only once during import

change text color for the method cad_wireframe in geometry_plot_pylab and add hide key
This commit is contained in:
2020-01-13 10:25:33 +01:00
parent 4fc4903dc2
commit 033cb92dc4
28 changed files with 1848 additions and 165 deletions

328
docs/build/html/pylib.tui.html vendored Normal file
View File

@@ -0,0 +1,328 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>pylib.tui module &#8212; pylib 2019.12.21 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="pylib.time_of_day module" href="pylib.time_of_day.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-pylib.tui">
<span id="pylib-tui-module"></span><h1>pylib.tui module<a class="headerlink" href="#module-pylib.tui" title="Permalink to this headline"></a></h1>
<p>TUI module.</p>
<dl class="field-list simple">
<dt class="field-odd">Date</dt>
<dd class="field-odd"><p>2020-01-10</p>
</dd>
</dl>
<span class="target" id="module-tui"></span><dl class="class">
<dt id="pylib.tui.StdOutWrapper">
<em class="property">class </em><code class="sig-name descname">StdOutWrapper</code><a class="reference internal" href="_modules/pylib/tui.html#StdOutWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.StdOutWrapper" title="Permalink 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>Send print to stdout (print to the standard console).</p>
<p>usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># catch all prints into StdOutWrapper</span>
<span class="n">mystdout</span> <span class="o">=</span> <span class="n">StdOutWrapper</span><span class="p">()</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stdout</span> <span class="o">=</span> <span class="n">mystdout</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stderr</span> <span class="o">=</span> <span class="n">mystdout</span>
<span class="c1"># begin curses (curses.initscr())</span>
<span class="c1"># do your stuff here</span>
<span class="c1"># print(&quot;foo&quot;)</span>
<span class="c1"># you can also output mystdout.get_text() in a ncurses widget in</span>
<span class="c1"># runtime</span>
<span class="c1"># end curses (curses.endwin())</span>
<span class="c1"># go back to normal state and print all catched prints to stdout</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stdout</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">__stdout__</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stderr</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">__stderr__</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">mystdout</span><span class="o">.</span><span class="n">get_text</span><span class="p">())</span>
</pre></div>
</div>
<dl class="simple">
<dt>source:</dt><dd><p><a class="reference external" href="https://stackoverflow.com/a/14010948">https://stackoverflow.com/a/14010948</a></p>
</dd>
</dl>
<dl class="method">
<dt id="pylib.tui.StdOutWrapper.get_text">
<code class="sig-name descname">get_text</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#StdOutWrapper.get_text"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.StdOutWrapper.get_text" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="pylib.tui.StdOutWrapper.text">
<code class="sig-name descname">text</code><em class="property"> = ''</em><a class="headerlink" href="#pylib.tui.StdOutWrapper.text" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.StdOutWrapper.write">
<code class="sig-name descname">write</code><span class="sig-paren">(</span><em class="sig-param">txt</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#StdOutWrapper.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.StdOutWrapper.write" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="pylib.tui.TUI">
<em class="property">class </em><code class="sig-name descname">TUI</code><span class="sig-paren">(</span><em class="sig-param">delay=5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI" title="Permalink 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>TUI text-based user interface</p>
<p>initscr is the encapsulation window object of the stdscr
stdsc is the curses.initscr</p>
<dl class="method">
<dt id="pylib.tui.TUI.clear">
<code class="sig-name descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI.clear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI.clear" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.TUI.color_def">
<code class="sig-name descname">color_def</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI.color_def"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI.color_def" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.TUI.color_table">
<code class="sig-name descname">color_table</code><span class="sig-paren">(</span><em class="sig-param">window=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI.color_table"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI.color_table" title="Permalink to this definition"></a></dt>
<dd><p>Print all available colors with default background.
Check if curses.has_colors() is True.</p>
</dd></dl>
<dl class="method">
<dt id="pylib.tui.TUI.end">
<code class="sig-name descname">end</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI.end"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI.end" title="Permalink to this definition"></a></dt>
<dd><p>clean up</p>
</dd></dl>
<dl class="method">
<dt id="pylib.tui.TUI.getch">
<code class="sig-name descname">getch</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI.getch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI.getch" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.TUI.refresh">
<code class="sig-name descname">refresh</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#TUI.refresh"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.TUI.refresh" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="pylib.tui.Window">
<em class="property">class </em><code class="sig-name descname">Window</code><a class="reference internal" href="_modules/pylib/tui.html#Window"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<dl class="method">
<dt id="pylib.tui.Window.border">
<code class="sig-name descname">border</code><span class="sig-paren">(</span><em class="sig-param">title=''</em>, <em class="sig-param">footer_left=''</em>, <em class="sig-param">footer_right=''</em>, <em class="sig-param">style='horizontal'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.border"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.border" title="Permalink to this definition"></a></dt>
<dd><p>Set border around the window with optional title and footer
labels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>window</strong> (<em>curses.window</em>) the window to draw a border</p></li>
<li><p><strong>title</strong> (<em>str</em>) the title for the window (default = “”)</p></li>
<li><p><strong>footer_left</strong> (<em>str</em><em> or </em><em>list</em>) the footer label (default = “”). If footer_left
is a list than every element of the list will be printed sperated
by one column. This is useful to not overwright the border with a
space character.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.clear">
<code class="sig-name descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.clear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.clear" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.derwin">
<code class="sig-name descname">derwin</code><span class="sig-paren">(</span><em class="sig-param">height</em>, <em class="sig-param">width</em>, <em class="sig-param">y</em>, <em class="sig-param">x</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.derwin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.derwin" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.getch">
<code class="sig-name descname">getch</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.getch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.getch" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.getmaxyx">
<code class="sig-name descname">getmaxyx</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.getmaxyx"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.getmaxyx" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.initscr">
<code class="sig-name descname">initscr</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.initscr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.initscr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.instr">
<code class="sig-name descname">instr</code><span class="sig-paren">(</span><em class="sig-param">y</em>, <em class="sig-param">x</em>, <em class="sig-param">n</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.instr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.instr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.refresh">
<code class="sig-name descname">refresh</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.refresh"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.refresh" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.text">
<code class="sig-name descname">text</code><span class="sig-paren">(</span><em class="sig-param">string</em>, <em class="sig-param">padding_left=0</em>, <em class="sig-param">padding_top=0</em>, <em class="sig-param">attribute=0</em>, <em class="sig-param">color_pair=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.text"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.text" title="Permalink to this definition"></a></dt>
<dd><p>Test to screen. If multiline than keep the x position for
each new line.</p>
<dl class="field-list simple">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">text</span><span class="p">(</span><span class="n">stdscr</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;1 - Show test page&quot;</span><span class="p">)</span>
<span class="n">text</span><span class="p">(</span><span class="n">stdscr</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;h - Show help page&quot;</span><span class="p">)</span>
<span class="n">text</span><span class="p">(</span><span class="n">stdscr</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">&quot;q - Exit&quot;</span><span class="p">)</span>
<span class="n">text</span><span class="p">(</span><span class="n">stdscr</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span>
<span class="s2">&quot;1 - Show test page</span><span class="se">\\</span><span class="s2">n&quot;</span> <span class="o">+</span>
<span class="s2">&quot;h - Show help page</span><span class="se">\\</span><span class="s2">n&quot;</span> <span class="o">+</span>
<span class="s2">&quot;q - Exit&quot;</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Writing in the last char of the window (last row bottom and
last column right) is suppressed</p>
</div>
</dd></dl>
<dl class="method">
<dt id="pylib.tui.Window.textbox">
<code class="sig-name descname">textbox</code><span class="sig-paren">(</span><em class="sig-param">height</em>, <em class="sig-param">width</em>, <em class="sig-param">y</em>, <em class="sig-param">x</em>, <em class="sig-param">borders=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#Window.textbox"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.Window.textbox" title="Permalink to this definition"></a></dt>
<dd><p>Add sub window.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>parent_window</strong> (<em>curses.window</em>) the parent window</p></li>
<li><p><strong>height</strong> (<em>int</em>) the height of the sub window. The reference point of
the sub window is the top left corner.</p></li>
<li><p><strong>width</strong> (<em>int</em>) the width of the sub window. The reference point of
the sub window is the top left corner.</p></li>
<li><p><strong>y</strong> (<em>int</em>) the y coordinate (position) of the sub window. Start from
the top.</p></li>
<li><p><strong>x</strong> the x coordinate (position) of the sub window. Start from
the left.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>the sub window content and decoration</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>(curses.window, curses.window)</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="pylib.tui.newwin">
<code class="sig-name descname">newwin</code><span class="sig-paren">(</span><em class="sig-param">height</em>, <em class="sig-param">width</em>, <em class="sig-param">y</em>, <em class="sig-param">x</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/tui.html#newwin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.tui.newwin" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">pylib</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="modules.html">pylib</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="pylib.html">pylib package</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li><a href="modules.html">pylib</a><ul>
<li><a href="pylib.html">pylib package</a><ul>
<li>Previous: <a href="pylib.time_of_day.html" title="previous chapter">pylib.time_of_day module</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
<div 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" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2019, Daniel Weschke.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/pylib.tui.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>