Browse Source

Doc Updated

gh-pages
Eugenio Parodi 4 years ago
parent
commit
c2f019f695
  1. 29
      _sources/tutorial/005-calculator.rst.txt
  2. 2
      searchindex.js
  3. 24
      tutorial/005-calculator.html

29
_sources/tutorial/005-calculator.rst.txt

@ -54,6 +54,11 @@ Initialize the window
From `calculator.001.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.001.py>`_
.. code:: bash
# If you want to try without installation, run from the pyTermTk root folder
PYTHONPATH=`pwd` tutorial/calculator/calculator.001.py
First thing first I need a parent widget with a grid layout that I can use to place the elements of my calculator
.. code:: python
@ -78,7 +83,12 @@ Add all the widgets of calculator to it
From `calculator.002.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.002.py>`_
Based on the positions and sizes defined in the :ref:`design layout <design>`, I place all the widgets on the TTkGridLayout_ (**winLayout**)
Based on the positions and sizes defined in the `design layout <#design>`_, I place all the widgets on the TTkGridLayout_ (**winLayout**)
.. code:: bash
# If you want to try without installation, run from the pyTermTk root folder
PYTHONPATH=`pwd` tutorial/calculator/calculator.002.py
.. code:: python
@ -86,7 +96,7 @@ Based on the positions and sizes defined in the :ref:`design layout <design>`, I
# Position (Row/Col) (0,0) and (Row/Col)Span (1,4)
# I force the Max Height to 1 in order to avoid this widget to resize vertically
resLabel = ttk.TTkLabel(text="Results", maxHeight=1)
winLayout.addWidget(resLabel, 0,0, 4,1)
winLayout.addWidget(resLabel, 0,0, 1,4)
# Define the Numeric Buttons and attach them to the grid layout
btn1 = ttk.TTkButton(border=True, text="1")
@ -154,6 +164,11 @@ Numeric Button Events
From `calculator.003.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.003.py>`_
.. code:: bash
# If you want to try without installation, run from the pyTermTk root folder
PYTHONPATH=`pwd` tutorial/calculator/calculator.003.py
.. code:: python
# I am defining a simlpe structure that can be used to store
@ -195,6 +210,11 @@ Operation and results events
From `calculator.004.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.004.py>`_
.. code:: bash
# If you want to try without installation, run from the pyTermTk root folder
PYTHONPATH=`pwd` tutorial/calculator/calculator.004.py
.. code:: python
# Define 2 slots to handle the Add and Sub operations
@ -233,6 +253,11 @@ Beware the Mystery Button
From `calculator.005.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.005.py>`_
.. code:: bash
# If you want to try without installation, run from the pyTermTk root folder
PYTHONPATH=`pwd` tutorial/calculator/calculator.005.py
.. code:: python
@pyTTkSlot()

2
searchindex.js

File diff suppressed because one or more lines are too long

24
tutorial/005-calculator.html

@ -224,6 +224,10 @@ Thanks to my amazing <a class="reference external" href="https://github.com/cecc
<section id="initialize-the-window">
<h3>Initialize the window<a class="headerlink" href="#initialize-the-window" title="Permalink to this headline"></a></h3>
<p>From <a class="reference external" href="https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.001.py">calculator.001.py</a></p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># If you want to try without installation, run from the pyTermTk root folder</span>
<span class="nv">PYTHONPATH</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span> tutorial/calculator/calculator.001.py
</pre></div>
</div>
<p>First thing first I need a parent widget with a grid layout that I can use to place the elements of my calculator</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">TermTk</span> <span class="k">as</span> <span class="nn">ttk</span>
@ -243,12 +247,16 @@ Thanks to my amazing <a class="reference external" href="https://github.com/cecc
<section id="add-all-the-widgets-of-calculator-to-it">
<h3>Add all the widgets of calculator to it<a class="headerlink" href="#add-all-the-widgets-of-calculator-to-it" title="Permalink to this headline"></a></h3>
<p>From <a class="reference external" href="https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.002.py">calculator.002.py</a></p>
<p>Based on the positions and sizes defined in the <a class="reference internal" href="#design"><span class="std std-ref">design layout</span></a>, I place all the widgets on the <a class="reference external" href="https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.gridlayout.html">TTkGridLayout</a> (<strong>winLayout</strong>)</p>
<p>Based on the positions and sizes defined in the <a class="reference external" href="#design">design layout</a>, I place all the widgets on the <a class="reference external" href="https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.gridlayout.html">TTkGridLayout</a> (<strong>winLayout</strong>)</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># If you want to try without installation, run from the pyTermTk root folder</span>
<span class="nv">PYTHONPATH</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span> tutorial/calculator/calculator.002.py
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Define the Label and attach it to the grid layout at</span>
<span class="c1"># Position (Row/Col) (0,0) and (Row/Col)Span (1,4)</span>
<span class="c1"># I force the Max Height to 1 in order to avoid this widget to resize vertically</span>
<span class="n">resLabel</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">TTkLabel</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;Results&quot;</span><span class="p">,</span> <span class="n">maxHeight</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">winLayout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">resLabel</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span><span class="mi">0</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="n">winLayout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">resLabel</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span>
<span class="c1"># Define the Numeric Buttons and attach them to the grid layout</span>
<span class="n">btn1</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">TTkButton</span><span class="p">(</span><span class="n">border</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">&quot;1&quot;</span><span class="p">)</span>
@ -312,6 +320,10 @@ Thanks to my amazing <a class="reference external" href="https://github.com/cecc
<section id="numeric-button-events">
<h3>Numeric Button Events<a class="headerlink" href="#numeric-button-events" title="Permalink to this headline"></a></h3>
<p>From <a class="reference external" href="https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.003.py">calculator.003.py</a></p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># If you want to try without installation, run from the pyTermTk root folder</span>
<span class="nv">PYTHONPATH</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span> tutorial/calculator/calculator.003.py
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># I am defining a simlpe structure that can be used to store</span>
<span class="c1"># the mathematical elements of the formulae</span>
<span class="n">mathElements</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;a&#39;</span><span class="p">:</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">:</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;operation&#39;</span><span class="p">:</span><span class="kc">None</span><span class="p">}</span>
@ -350,6 +362,10 @@ Thanks to my amazing <a class="reference external" href="https://github.com/cecc
<section id="operation-and-results-events">
<h3>Operation and results events<a class="headerlink" href="#operation-and-results-events" title="Permalink to this headline"></a></h3>
<p>From <a class="reference external" href="https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.004.py">calculator.004.py</a></p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># If you want to try without installation, run from the pyTermTk root folder</span>
<span class="nv">PYTHONPATH</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span> tutorial/calculator/calculator.004.py
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Define 2 slots to handle the Add and Sub operations</span>
<span class="nd">@pyTTkSlot</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">setOperationAdd</span><span class="p">():</span>
@ -385,6 +401,10 @@ Thanks to my amazing <a class="reference external" href="https://github.com/cecc
<section id="beware-the-mystery-button">
<h3>Beware the Mystery Button<a class="headerlink" href="#beware-the-mystery-button" title="Permalink to this headline"></a></h3>
<p>From <a class="reference external" href="https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/calculator/calculator.005.py">calculator.005.py</a></p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># If you want to try without installation, run from the pyTermTk root folder</span>
<span class="nv">PYTHONPATH</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span> tutorial/calculator/calculator.005.py
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@pyTTkSlot</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">showAboytWindow</span><span class="p">():</span>
<span class="c1"># I am using the overlay helper to show the</span>

Loading…
Cancel
Save