Commit 17cbb1a3 authored by Etienne Nadji's avatar Etienne Nadji
Browse files

modifié : _sources/guide/en/quickstart.rst.txt

	modifié :         _sources/index.rst.txt
	modifié :         guide/en/quickstart.html
	modifié :         index.html
	modifié :         searchindex.js
parent 2da99c0a
......@@ -2,6 +2,29 @@
Quickstart
**********
Install PyScribus
=================
Pip
---
PyScribus is available through pip :
**For Python versions >= 3.8 :**
``pip install pyscribus``
**For older Python versions :**
``pip install -i https://test.pypi.org/simple/ pyscribus-backported``
Git
---
The code of PyScribus is available as a GIT repository on Framagit.
``git clone https://framagit.org/etnadji/pyscribus.git``
An introduction to PyScribus modules
====================================
......@@ -92,7 +115,78 @@ most of the other ones.
Basics of PyScribus objects
===========================
TODO: fromdefault(), pyscribus_defaults attribute, listdefaults()
Each PyScribus object corresponding to a objet in the SLA source file, for
example, a color definition, a paragraph style… has some common methods.
Defaults
--------
You can import default attributes of a PyScribus object with `.fromdefault`
method. Sometimes, there is not one set of defaults attributes but many (for
example, the colors included in every new Scribus document); in that case, you
would find the set name with `.listdefaults` method and
in `pyscribus_defaults` attributes.
::
import pyscribus.colors as colors
black = colors.Color()
black.listdefaults()
# ['Black',
# 'Blue',
# 'Cool Black',
# 'Cyan',
# 'Green',
# 'Magenta',
# 'Red',
# 'Registration',
# 'Rich Black',
# 'Warm Black',
# 'White',
# 'Yellow']
# For the Color object, no set name -> Black set.
black.fromdefault()
# {'C': 0.0, 'M': 0.0, 'Y': 0.0, 'K': 100.0}, True
print(black.colors, black.is_cmyk)
red = colors.Color()
# Red, Green, Blue are default colors in RGB color space
red.fromdefault("Red")
# {'R': 255.0, 'G': 0.0, 'B': 0.0}, False
print(red.colors, red.is_cmyk)
XML
---
The SLA file format is an XML one. So if you only want to convert a portion
of a SLA file into a Python object, you can do that with the `.fromxml` method.
::
import lxml.etree as ET
import pyscribus.colors as colors
# SLA color definition -----------------------
code = '<COLOR NAME="Black" SPACE="CMYK" C="0" M="0" Y="0" K="100"/>'
# Create the color object and load from code -
source = ET.fromstring(code)
color = colors.Color()
color.fromxml(source)
# --------------------------------------------
# {'C': 0.0, 'M': 0.0, 'Y': 0.0, 'K': 100.0}, True
print(color.colors, color.is_cmyk)
Measures and geometry in PyScribus
==================================
......
......@@ -4,8 +4,14 @@ PyScribus
Read, create and update Scribus .sla files.
**For Python versions >= 3.8**
``pip install pyscribus``
**For older Python versions**
``pip install -i https://test.pypi.org/simple/ pyscribus-backported``
-------------------
User Guide
......
......@@ -90,6 +90,11 @@
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Quickstart</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#install-pyscribus">Install PyScribus</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#pip">Pip</a></li>
<li class="toctree-l3"><a class="reference internal" href="#git">Git</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#an-introduction-to-pyscribus-modules">An introduction to PyScribus modules</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#used-for-parsing-generating">Used for parsing &amp; generating</a></li>
<li class="toctree-l3"><a class="reference internal" href="#paper-sizes">Paper sizes</a></li>
......@@ -97,7 +102,11 @@
<li class="toctree-l3"><a class="reference internal" href="#basis">Basis</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#basics-of-pyscribus-objects">Basics of PyScribus objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="#basics-of-pyscribus-objects">Basics of PyScribus objects</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#defaults">Defaults</a></li>
<li class="toctree-l3"><a class="reference internal" href="#xml">XML</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#measures-and-geometry-in-pyscribus">Measures and geometry in PyScribus</a></li>
<li class="toctree-l2"><a class="reference internal" href="#frequent-tasks">Frequent tasks</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#reading-an-existing-sla-file">Reading an existing SLA file</a></li>
......@@ -109,20 +118,21 @@
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../fr/general.html">[FR] Fonctionnement général</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fr/dims.html">[FR] Mesures et autres nombres</a></li>
<li class="toctree-l1"><a class="reference internal" href="psm.html">PyScribus Story Markup</a></li>
<li class="toctree-l1"><a class="reference internal" href="templating.html">PyScribus templating</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../credits.html">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../thanks.html">Acknowledgements</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../forhumans.html">Scribus SLA for humans</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">PyScribus reference</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../articles/en/spec.html">[EN] SLA document-able attributes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../articles/en/spec-suggestions.html">SLA’s enhancement suggestions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../articles/fr/stories.html">[FR] Comment les <em>stories</em> de Scribus (semblent) fonctionner</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../articles/en/spec-suggestions.html">[EN] SLA’s enhancement suggestions</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../credits.html">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../thanks.html">Acknowledgements</a></li>
</ul>
......@@ -189,6 +199,22 @@
<div class="section" id="quickstart">
<h1>Quickstart<a class="headerlink" href="#quickstart" title="Permalink to this headline"></a></h1>
<div class="section" id="install-pyscribus">
<h2>Install PyScribus<a class="headerlink" href="#install-pyscribus" title="Permalink to this headline"></a></h2>
<div class="section" id="pip">
<h3>Pip<a class="headerlink" href="#pip" title="Permalink to this headline"></a></h3>
<p>PyScribus is available through pip :</p>
<p><strong>For Python versions &gt;= 3.8 :</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">pyscribus</span></code></p>
<p><strong>For older Python versions :</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-i</span> <span class="pre">https://test.pypi.org/simple/</span> <span class="pre">pyscribus-backported</span></code></p>
</div>
<div class="section" id="git">
<h3>Git<a class="headerlink" href="#git" title="Permalink to this headline"></a></h3>
<p>The code of PyScribus is available as a GIT repository on Framagit.</p>
<p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">https://framagit.org/etnadji/pyscribus.git</span></code></p>
</div>
</div>
<div class="section" id="an-introduction-to-pyscribus-modules">
<h2>An introduction to PyScribus modules<a class="headerlink" href="#an-introduction-to-pyscribus-modules" title="Permalink to this headline"></a></h2>
<div class="section" id="used-for-parsing-generating">
......@@ -342,7 +368,77 @@ most of the other ones.</p>
</div>
<div class="section" id="basics-of-pyscribus-objects">
<h2>Basics of PyScribus objects<a class="headerlink" href="#basics-of-pyscribus-objects" title="Permalink to this headline"></a></h2>
<p>TODO: fromdefault(), pyscribus_defaults attribute, listdefaults()</p>
<p>Each PyScribus object corresponding to a objet in the SLA source file, for
example, a color definition, a paragraph style… has some common methods.</p>
<div class="section" id="defaults">
<h3>Defaults<a class="headerlink" href="#defaults" title="Permalink to this headline"></a></h3>
<p>You can import default attributes of a PyScribus object with <cite>.fromdefault</cite>
method. Sometimes, there is not one set of defaults attributes but many (for
example, the colors included in every new Scribus document); in that case, you
would find the set name with <cite>.listdefaults</cite> method and
in <cite>pyscribus_defaults</cite> attributes.</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pyscribus.colors</span> <span class="k">as</span> <span class="nn">colors</span>
<span class="n">black</span> <span class="o">=</span> <span class="n">colors</span><span class="o">.</span><span class="n">Color</span><span class="p">()</span>
<span class="n">black</span><span class="o">.</span><span class="n">listdefaults</span><span class="p">()</span>
<span class="c1"># [&#39;Black&#39;,</span>
<span class="c1"># &#39;Blue&#39;,</span>
<span class="c1"># &#39;Cool Black&#39;,</span>
<span class="c1"># &#39;Cyan&#39;,</span>
<span class="c1"># &#39;Green&#39;,</span>
<span class="c1"># &#39;Magenta&#39;,</span>
<span class="c1"># &#39;Red&#39;,</span>
<span class="c1"># &#39;Registration&#39;,</span>
<span class="c1"># &#39;Rich Black&#39;,</span>
<span class="c1"># &#39;Warm Black&#39;,</span>
<span class="c1"># &#39;White&#39;,</span>
<span class="c1"># &#39;Yellow&#39;]</span>
<span class="c1"># For the Color object, no set name -&gt; Black set.</span>
<span class="n">black</span><span class="o">.</span><span class="n">fromdefault</span><span class="p">()</span>
<span class="c1"># {&#39;C&#39;: 0.0, &#39;M&#39;: 0.0, &#39;Y&#39;: 0.0, &#39;K&#39;: 100.0}, True</span>
<span class="nb">print</span><span class="p">(</span><span class="n">black</span><span class="o">.</span><span class="n">colors</span><span class="p">,</span> <span class="n">black</span><span class="o">.</span><span class="n">is_cmyk</span><span class="p">)</span>
<span class="n">red</span> <span class="o">=</span> <span class="n">colors</span><span class="o">.</span><span class="n">Color</span><span class="p">()</span>
<span class="c1"># Red, Green, Blue are default colors in RGB color space</span>
<span class="n">red</span><span class="o">.</span><span class="n">fromdefault</span><span class="p">(</span><span class="s2">&quot;Red&quot;</span><span class="p">)</span>
<span class="c1"># {&#39;R&#39;: 255.0, &#39;G&#39;: 0.0, &#39;B&#39;: 0.0}, False</span>
<span class="nb">print</span><span class="p">(</span><span class="n">red</span><span class="o">.</span><span class="n">colors</span><span class="p">,</span> <span class="n">red</span><span class="o">.</span><span class="n">is_cmyk</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="xml">
<h3>XML<a class="headerlink" href="#xml" title="Permalink to this headline"></a></h3>
<p>The SLA file format is an XML one. So if you only want to convert a portion
of a SLA file into a Python object, you can do that with the <cite>.fromxml</cite> method.</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">lxml.etree</span> <span class="k">as</span> <span class="nn">ET</span>
<span class="kn">import</span> <span class="nn">pyscribus.colors</span> <span class="k">as</span> <span class="nn">colors</span>
<span class="c1"># SLA color definition -----------------------</span>
<span class="n">code</span> <span class="o">=</span> <span class="s1">&#39;&lt;COLOR NAME=&quot;Black&quot; SPACE=&quot;CMYK&quot; C=&quot;0&quot; M=&quot;0&quot; Y=&quot;0&quot; K=&quot;100&quot;/&gt;&#39;</span>
<span class="c1"># Create the color object and load from code -</span>
<span class="n">source</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">fromstring</span><span class="p">(</span><span class="n">code</span><span class="p">)</span>
<span class="n">color</span> <span class="o">=</span> <span class="n">colors</span><span class="o">.</span><span class="n">Color</span><span class="p">()</span>
<span class="n">color</span><span class="o">.</span><span class="n">fromxml</span><span class="p">(</span><span class="n">source</span><span class="p">)</span>
<span class="c1"># --------------------------------------------</span>
<span class="c1"># {&#39;C&#39;: 0.0, &#39;M&#39;: 0.0, &#39;Y&#39;: 0.0, &#39;K&#39;: 100.0}, True</span>
<span class="nb">print</span><span class="p">(</span><span class="n">color</span><span class="o">.</span><span class="n">colors</span><span class="p">,</span> <span class="n">color</span><span class="o">.</span><span class="n">is_cmyk</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
</div>
</div>
<div class="section" id="measures-and-geometry-in-pyscribus">
<h2>Measures and geometry in PyScribus<a class="headerlink" href="#measures-and-geometry-in-pyscribus" title="Permalink to this headline"></a></h2>
......
......@@ -172,7 +172,10 @@
<div class="section" id="pyscribus">
<h1>PyScribus<a class="headerlink" href="#pyscribus" title="Permalink to this headline"></a></h1>
<p>Read, create and update Scribus .sla files.</p>
<p><strong>For Python versions &gt;= 3.8</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">pyscribus</span></code></p>
<p><strong>For older Python versions</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-i</span> <span class="pre">https://test.pypi.org/simple/</span> <span class="pre">pyscribus-backported</span></code></p>
<hr class="docutils" />
<div class="section" id="user-guide">
<h2>User Guide<a class="headerlink" href="#user-guide" title="Permalink to this headline"></a></h2>
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment