Browse Source

Add basic SignalSlots info

pull/12/head
Eugenio Parodi 5 years ago
parent
commit
c19271958c
  1. 1
      TermTk/TTkCore/canvas.py
  2. 1
      TermTk/TTkCore/constant.py
  3. 30
      TermTk/TTkCore/signal.py
  4. 2
      TermTk/TTkWidgets/widget.py
  5. 3
      docs/images/Signal.Slots.001.svg
  6. 0
      docs/images/hld.svg
  7. 1
      docs/source/_static/Signal.Slots.001.svg
  8. 5
      docs/source/index.rst
  9. 13
      tutorial/003-signalslots.md

1
TermTk/TTkCore/canvas.py

@ -45,7 +45,6 @@ class TTkCanvas:
'_bufferedData', '_bufferedColors',
'_visible', '_doubleBuffer')
def __init__(self, *args, **kwargs):
self._widget = kwargs.get('widget', None)
self._visible = True
self._doubleBuffer = False

1
TermTk/TTkCore/constant.py

@ -138,7 +138,6 @@ class TTkConstant:
RIGHT_ALIGN
CENTER_ALIGN
JUSTIFY
pippo
'''
NONE = 0x0000
''' No Alignment'''

30
TermTk/TTkCore/signal.py

@ -27,7 +27,35 @@
# https://github.com/ceccopierangiolieugenio/pyCuT/blob/master/cupy/CuTCore/CuSignal.py
'''
[Tutorial](https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/003-signalslots.md)
Signals & Slots [`Tutorial <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/003-signalslots.md>`_]
=========================
Signals and slots are used for communication between objects.
Intro
=====
| The :mod:`TermTk.TTkCore.signal` is more than heavily inspired by `Qt5 Signal&Slots <(https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html>`_
| https://doc.qt.io/qt-5/signalsandslots.html
| In GUI programming, when we change one widget, we often want another widget to be notified.
| More generally, we want objects of any kind to be able to communicate with one another.
| For example, if a user clicks a Close button, we probably want the window's close() function to be called.
Signal and Slots
================
| A signal is emitted when a particular event occurs.
| A slot is a function that is called in response to a particular signal.
| `TermTk <https://github.com/ceccopierangiolieugenio/pyTermTk>`_'s :mod:`~TermTk.TTkWidgets` have many predefined signals/slots, but it is possible to subclass any :mod:`~TermTk.TTkWidgets` and add our own signals/slots to them.
.. image:: /../_static/Signal.Slots.001.svg
Methods
=======
.. autofunction:: TermTk.pyTTkSignal
.. autodecorator:: TermTk.pyTTkSlot
'''
def pyTTkSlot(*args, **kwargs):
def pyTTkSlot_d(func):

2
TermTk/TTkWidgets/widget.py

@ -167,7 +167,7 @@ class TTkWidget(TMouseEvents,TKeyEvents):
def paintEvent(self):
'''
Pain Event callback,
Paint Event callback,
ths need to be overridden in the widget.
'''
pass

3
docs/images/Signal.Slots.001.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 22 KiB

0
docs/hld.svg → docs/images/hld.svg

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

1
docs/source/_static/Signal.Slots.001.svg

@ -0,0 +1 @@
../../images/Signal.Slots.001.svg

5
docs/source/index.rst

@ -12,11 +12,6 @@ Welcome to pyTermTk's documentation!
autogen.TermTk/TermTk.rst
TermTk main
===================
.. autoclass:: TermTk.TTkButton
.. autodecorator:: TermTk.pyTTkSlot
Indices and tables
==================

13
tutorial/003-signalslots.md

@ -1,9 +1,20 @@
# [pyTermTk](https://github.com/ceccopierangiolieugenio/pyTermTk) - Signal & Slots
Signals and slots are used for communication between objects.
## Intro
The [TermTk Signal&Slots](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/signal.html) and more than heavily inspired by [Qt5 Signal&Slots](https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html)
The [TermTk Signal&Slots](https://ceccopierangiolieugenio.github.io/pyTermTk/TTkCore/signal.html) is more than heavily inspired by [Qt5 Signal&Slots](https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html)
https://doc.qt.io/qt-5/signalsandslots.html
In GUI programming, when we change one widget, we often want another widget to be notified. More generally, we want objects of any kind to be able to communicate with one another. For example, if a user clicks a Close button, we probably want the window's close() function to be called.
## Signal and Slots
A signal is emitted when a particular event occurs. <br/>
A slot is a function that is called in response to a particular signal. <br/>
[TermTk](https://github.com/ceccopierangiolieugenio/pyTermTk)'s [widgets](https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.html) have many predefined signals/slots, but it is possible to subclass any [widgets](https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.html) and add our own signals/slots to them.
![Signal/Slots](../docs/images/Signal.Slots.001.svg)
## Example 1 - basic signal slots
From [example1.basic.signalslots.py](signalslots/example1.basic.signalslots.py)

Loading…
Cancel
Save