Browse Source

Improved documentation

pull/5/head
Eugenio Parodi 5 years ago
parent
commit
44b89671eb
  1. 60
      TermTk/TTkCore/signal.py
  2. 3
      TermTk/TTkLayouts/boxlayout.py
  3. 26
      TermTk/TTkLayouts/gridlayout.py
  4. 3
      TermTk/TTkLayouts/layout.py

60
TermTk/TTkCore/signal.py

@ -23,12 +23,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ref: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html
# https://github.com/ceccopierangiolieugenio/pyCuT/blob/master/cupy/CuTCore/CuSignal.py
'''
ref: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html
https://github.com/ceccopierangiolieugenio/pyCuT/blob/master/cupy/CuTCore/CuSignal.py
[Tutorial](https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/003-signalslots.md)
'''
# dummy decorator
def pyTTkSlot(*args, **kwargs):
def pyTTkSlot_d(func):
# Add signature attributes to the function
@ -37,44 +37,40 @@ def pyTTkSlot(*args, **kwargs):
return pyTTkSlot_d
def pyTTkSignal(*args, **kwargs):
return pyTTkSignal_obj(*args, **kwargs)
class pyTTkSignal_obj():
'''
ref: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#PyQt5.QtCore.pyqtSignal
PyQt5.QtCore.pyqtSignal(types[, name[, revision=0[, arguments=[]]]])
Create one or more overloaded unbound signals as a class attribute.
return _pyTTkSignal_obj(*args, **kwargs)
Parameters:
types - the types that define the C++ signature of the signal. Each type may be a Python type object or a string that is the name of a C++ type. Alternatively each may be a sequence of type arguments. In this case each sequence defines the signature of a different signal overload. The first overload will be the default.
name - the name of the signal. If it is omitted then the name of the class attribute is used. This may only be given as a keyword argument.
revision - the revision of the signal that is exported to QML. This may only be given as a keyword argument.
arguments - the sequence of the names of the signal's arguments that is exported to QML. This may only be given as a keyword argument.
Return type:
an unbound signal
'''
class _pyTTkSignal_obj():
__slots__ = ('_types', '_name', '_revision', '_connected_slots')
def __init__(self, *args, **kwargs):
# ref: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#PyQt5.QtCore.pyqtSignal
# PyQt5.QtCore.pyqtSignal(types[, name[, revision=0[, arguments=[]]]])
# Create one or more overloaded unbound signals as a class attribute.
# Parameters:
# types - the types that define the C++ signature of the signal. Each type may be a Python type object or a string that is the name of a C++ type. Alternatively each may be a sequence of type arguments. In this case each sequence defines the signature of a different signal overload. The first overload will be the default.
# name - the name of the signal. If it is omitted then the name of the class attribute is used. This may only be given as a keyword argument.
# revision - the revision of the signal that is exported to QML. This may only be given as a keyword argument.
# arguments - the sequence of the names of the signal's arguments that is exported to QML. This may only be given as a keyword argument.
# Return type:
# an unbound signal
self._types = args
self._name = kwargs.get('name', None)
self._revision = kwargs.get('revision', 0)
self._connected_slots = []
'''
ref: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#connect
def connect(self, slot):
# ref: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#connect
connect(slot[, type=PyQt5.QtCore.Qt.AutoConnection[, no_receiver_check=False]]) -> PyQt5.QtCore.QMetaObject.Connection
Connect a signal to a slot. An exception will be raised if the connection failed.
# connect(slot[, type=PyQt5.QtCore.Qt.AutoConnection[, no_receiver_check=False]]) -> PyQt5.QtCore.QMetaObject.Connection
# Connect a signal to a slot. An exception will be raised if the connection failed.
Parameters:
slot - the slot to connect to, either a Python callable or another bound signal.
type - the type of the connection to make.
no_receiver_check - suppress the check that the underlying C++ receiver instance still exists and deliver the signal anyway.
Returns:
a Connection object which can be passed to disconnect(). This is the only way to disconnect a connection to a lambda function.
'''
def connect(self, slot):
# Parameters:
# slot - the slot to connect to, either a Python callable or another bound signal.
# type - the type of the connection to make.
# no_receiver_check - suppress the check that the underlying C++ receiver instance still exists and deliver the signal anyway.
# Returns:
# a Connection object which can be passed to disconnect(). This is the only way to disconnect a connection to a lambda function.
if hasattr(slot, '_TTkslot_attr') and slot._TTkslot_attr != self._types:
error = "Decorated slot has no signature compatible: "+slot.__name__+str(slot._TTkslot_attr)+" != signal"+str(self._types)
raise TypeError(error)

3
TermTk/TTkLayouts/boxlayout.py

@ -23,7 +23,8 @@
# SOFTWARE.
'''
Layout System
### Box Layout
[Tutorial](https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/002-layout.md)
'''
from TermTk.TTkCore.log import TTkLog

26
TermTk/TTkLayouts/gridlayout.py

@ -23,7 +23,24 @@
# SOFTWARE.
'''
Layout System
### Grid Layout
[Tutorial](https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/002-layout.md)
The grid layout allows an automatic place all the widgets in a grid
the empty rows/cols are resized to the "columnMinHeight,columnMinWidth" parameters
TTkGridLayout columnMinWidth
Widget1 Widget2 Widget3
(0,0) (0,1) (0,3)
columnMinHeight
Widget4
(2,0)
Widget5
(3,3)
'''
from TermTk.TTkCore.constant import TTkK
@ -33,6 +50,13 @@ from TermTk.TTkLayouts.layout import TTkLayout, TTkWidgetItem
class TTkGridLayout(TTkLayout):
__slots__ = ('_gridItems','_columnMinWidth','_columnMinHeight')
def __init__(self, *args, **kwargs):
'''
TTkGridLayout constructor
Args:
columnMinWidth (int, optional, default=0): the minimum width of the column
columnMinHeight (int, optional, default=0): the minimum height of the column
'''
TTkLayout.__init__(self, *args, **kwargs)
self._gridItems = [[]]
self._columnMinWidth = kwargs.get('columnMinWidth',0)

3
TermTk/TTkLayouts/layout.py

@ -23,7 +23,8 @@
# SOFTWARE.
'''
Layout System
### Layout
[Tutorial](https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/002-layout.md)
'''
from TermTk.TTkCore.log import TTkLog

Loading…
Cancel
Save