pyqtgraph/documentation/build/html/_modules/pyqtgraph.html

192 lines
15 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pyqtgraph &mdash; pyqtgraph v1.8 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '1.8',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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>
<link rel="top" title="pyqtgraph v1.8 documentation" href="../index.html" />
<link rel="up" title="Module code" href="index.html" />
</head>
<body>
<div class="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><a href="../index.html">pyqtgraph v1.8 documentation</a> &raquo;</li>
<li><a href="index.html" accesskey="U">Module code</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>Source code for pyqtgraph</h1><div class="highlight"><pre>
<span class="c"># -*- coding: utf-8 -*-</span>
<span class="c">### import all the goodies and add some helper functions for easy CLI use</span>
<span class="c">## &#39;Qt&#39; is a local module; it is intended mainly to cover up the differences</span>
<span class="c">## between PyQt4 and PySide.</span>
<span class="kn">from</span> <span class="nn">Qt</span> <span class="kn">import</span> <span class="n">QtGui</span>
<span class="n">CONFIG_OPTIONS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">&#39;leftButtonPan&#39;</span><span class="p">:</span> <span class="bp">True</span>
<span class="p">}</span>
<span class="k">def</span> <span class="nf">setConfigOption</span><span class="p">(</span><span class="n">opt</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="n">CONFIG_OPTIONS</span><span class="p">[</span><span class="n">opt</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">def</span> <span class="nf">getConfigOption</span><span class="p">(</span><span class="n">opt</span><span class="p">):</span>
<span class="k">return</span> <span class="n">CONFIG_OPTIONS</span><span class="p">[</span><span class="n">opt</span><span class="p">]</span>
<span class="c">## Import almost everything to make it available from a single namespace</span>
<span class="c">## don&#39;t import the more complex systems--canvas, parametertree, flowchart, dockarea</span>
<span class="c">## these must be imported separately.</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="k">def</span> <span class="nf">importAll</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="n">d</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">__file__</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span> <span class="n">path</span><span class="p">)</span>
<span class="n">files</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">d</span><span class="p">):</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">f</span><span class="p">)):</span>
<span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">f</span><span class="p">[</span><span class="o">-</span><span class="mi">3</span><span class="p">:]</span> <span class="o">==</span> <span class="s">&#39;.py&#39;</span> <span class="ow">and</span> <span class="n">f</span> <span class="o">!=</span> <span class="s">&#39;__init__.py&#39;</span><span class="p">:</span>
<span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">f</span><span class="p">[:</span><span class="o">-</span><span class="mi">3</span><span class="p">])</span>
<span class="k">for</span> <span class="n">modName</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
<span class="n">mod</span> <span class="o">=</span> <span class="nb">__import__</span><span class="p">(</span><span class="n">path</span><span class="o">+</span><span class="s">&quot;.&quot;</span><span class="o">+</span><span class="n">modName</span><span class="p">,</span> <span class="nb">globals</span><span class="p">(),</span> <span class="nb">locals</span><span class="p">(),</span> <span class="n">fromlist</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;*&#39;</span><span class="p">])</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">mod</span><span class="p">,</span> <span class="s">&#39;__all__&#39;</span><span class="p">):</span>
<span class="n">names</span> <span class="o">=</span> <span class="n">mod</span><span class="o">.</span><span class="n">__all__</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="n">n</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">mod</span><span class="p">)</span> <span class="k">if</span> <span class="n">n</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s">&#39;_&#39;</span><span class="p">]</span>
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">mod</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
<span class="nb">globals</span><span class="p">()[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">mod</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
<span class="n">importAll</span><span class="p">(</span><span class="s">&#39;graphicsItems&#39;</span><span class="p">)</span>
<span class="n">importAll</span><span class="p">(</span><span class="s">&#39;widgets&#39;</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">imageview</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">WidgetGroup</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">Point</span> <span class="kn">import</span> <span class="n">Point</span>
<span class="kn">from</span> <span class="nn">Transform</span> <span class="kn">import</span> <span class="n">Transform</span>
<span class="kn">from</span> <span class="nn">functions</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">graphicsWindows</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">SignalProxy</span> <span class="kn">import</span> <span class="o">*</span>
<span class="c">## Convenience functions for command-line use</span>
<span class="n">plots</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">images</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">QAPP</span> <span class="o">=</span> <span class="bp">None</span>
<div class="viewcode-block" id="plot"><a class="viewcode-back" href="../functions.html#pyqtgraph.plot">[docs]</a><span class="k">def</span> <span class="nf">plot</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> | Create and return a PlotWindow (this is just a window with PlotWidget inside), plot data in it.</span>
<span class="sd"> | Accepts a *title* argument to set the title of the window.</span>
<span class="sd"> | All other arguments are used to plot data. (see :func:`PlotItem.plot() &lt;pyqtgraph.PlotItem.plot&gt;`)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">mkQApp</span><span class="p">()</span>
<span class="k">if</span> <span class="s">&#39;title&#39;</span> <span class="ow">in</span> <span class="n">kargs</span><span class="p">:</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">PlotWindow</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="n">kargs</span><span class="p">[</span><span class="s">&#39;title&#39;</span><span class="p">])</span>
<span class="k">del</span> <span class="n">kargs</span><span class="p">[</span><span class="s">&#39;title&#39;</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">PlotWindow</span><span class="p">()</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span><span class="o">+</span><span class="nb">len</span><span class="p">(</span><span class="n">kargs</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">w</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
<span class="n">plots</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">w</span><span class="p">)</span>
<span class="n">w</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
<span class="k">return</span> <span class="n">w</span>
</div>
<div class="viewcode-block" id="image"><a class="viewcode-back" href="../functions.html#pyqtgraph.image">[docs]</a><span class="k">def</span> <span class="nf">image</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> | Create and return an ImageWindow (this is just a window with ImageView widget inside), show image data inside.</span>
<span class="sd"> | Will show 2D or 3D image data.</span>
<span class="sd"> | Accepts a *title* argument to set the title of the window.</span>
<span class="sd"> | All other arguments are used to show data. (see :func:`ImageView.setImage() &lt;pyqtgraph.ImageView.setImage&gt;`)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">mkQApp</span><span class="p">()</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">ImageWindow</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
<span class="n">images</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">w</span><span class="p">)</span>
<span class="n">w</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
<span class="k">return</span> <span class="n">w</span></div>
<span class="n">show</span> <span class="o">=</span> <span class="n">image</span> <span class="c">## for backward compatibility</span>
<span class="k">def</span> <span class="nf">mkQApp</span><span class="p">():</span>
<span class="k">if</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QApplication</span><span class="o">.</span><span class="n">instance</span><span class="p">()</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">global</span> <span class="n">QAPP</span>
<span class="n">QAPP</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QApplication</span><span class="p">([])</span>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="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><a href="../index.html">pyqtgraph v1.8 documentation</a> &raquo;</li>
<li><a href="index.html" >Module code</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011, Luke Campagnola.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
</div>
</body>
</html>