Browse Source

Removed unrequired trailing spaces

pull/317/head
Eugenio Parodi 🌶️ 1 year ago
parent
commit
7050c8faec
  1. 2
      TermTk/TTkAbstract/abstractscrollview.py
  2. 2
      TermTk/TTkCore/TTkTerm/inputmouse.py
  3. 2
      TermTk/TTkCore/canvas.py
  4. 2
      TermTk/TTkCore/log.py
  5. 2
      TermTk/TTkCore/ttk.py
  6. 12
      TermTk/TTkGui/drag.py
  7. 4
      TermTk/TTkGui/textcursor.py
  8. 2
      TermTk/TTkTestWidgets/testabstractscroll.py
  9. 6
      TermTk/TTkWidgets/combobox.py
  10. 28
      TermTk/TTkWidgets/listwidget.py
  11. 2
      TermTk/TTkWidgets/widget.py
  12. 6
      docs/MDNotes/DumbPaintTool.TODO.md
  13. 2
      docs/MDNotes/Fonts/Font2Glyph.md
  14. 2
      docs/MDNotes/input/abstracrt.md
  15. 4
      docs/MDNotes/msWindows/Init Sequence.md
  16. 2
      docs/MDNotes/terminal/escape.screen.md
  17. 2
      docs/MDNotes/terminal/xterm.ctrlseq.md
  18. 28
      docs/source/info/resources/dragdrop.rst
  19. 12
      docs/source/sphinx_modules/sandbox_links.py
  20. 2
      docs/sphynx.001.signal.patch
  21. 2
      multiplexers/workbench/eumigo.txt
  22. 4
      tests/t.draw/test.draw.009.colorMix.py
  23. 2
      tests/t.generic/test.asyncio.001.multi.loop.py
  24. 16
      tests/t.ui/test.ui.018.TextEdit.04.Pygments.py
  25. 40
      tools/webExporter/eumigo.Ansi.txt
  26. 6
      tutorial/examples/DragAndDrop/dnd.01.basic.py
  27. 6
      tutorial/examples/DragAndDrop/dnd.02.events.01.py
  28. 18
      tutorial/examples/DragAndDrop/dnd.02.events.02.py
  29. 6
      tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py
  30. 18
      tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py
  31. 6
      tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py
  32. 4
      tutorial/examples/DragAndDrop/dnd.03.pixmap.04.py
  33. 8
      tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py

2
TermTk/TTkAbstract/abstractscrollview.py

@ -180,7 +180,7 @@ class TTkAbstractScrollView(TTkContainer, TTkAbstractScrollViewInterface):
t,b,l,r = self.getPadding()
_,_,w,h = self.layout().fullWidgetAreaGeometry()
return w+l+r, h+t+b
@pyTTkSlot(int, int)
def viewMoveTo(self, x: int, y: int):
fw, fh = self.viewFullAreaSize()

2
TermTk/TTkCore/TTkTerm/inputmouse.py

@ -92,7 +92,7 @@ class TTkMouseEvent:
self.mod = mod
self.raw = raw
self.tap = tap
def pos(self) -> tuple[int,int]:
'''
Returns the position of the mouse cursor relative to the current widget.

2
TermTk/TTkCore/canvas.py

@ -236,7 +236,7 @@ class TTkCanvas():
self._data[y][x+a:x+b] = txt[a:b]
if forceColor:
colors=[color]*len(colors)
else:
else:
for i in range(a,b):
if color != TTkColor.RST:
self._colors[y][x+i] = (colors[i] | color).mod(x+i,y)

2
TermTk/TTkCore/log.py

@ -80,7 +80,7 @@ class TTkLog:
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe,1)
if len(calframe) > 2:
ctx = _TTkContext(calframe[2])
ctx = _TTkContext(calframe[2])
for txt in str(msg).split('\n'):
cb(mode, ctx, txt)

2
TermTk/TTkCore/ttk.py

@ -29,7 +29,7 @@ import queue
import threading
import platform
from TermTk.TTkCore.drivers import *
from TermTk.TTkCore.drivers import TTkSignalDriver
from TermTk.TTkCore.TTkTerm.input import TTkInput
from TermTk.TTkCore.TTkTerm.inputkey import TTkKeyEvent
from TermTk.TTkCore.TTkTerm.inputmouse import TTkMouseEvent

12
TermTk/TTkGui/drag.py

@ -81,14 +81,14 @@ class TTkDnD():
:rtype: Any
'''
return self._data
def setHotSpot(self, pos:tuple[int,int]) -> None:
'''
Sets the position of the hot spot relative to the top-left corner of the pixmap used to the point specified by hotspot.
:param pos: the hotspot position
:type pos: tuple[int,int]
'''
'''
self._hotSpot = pos
def hotSpot(self) -> tuple[int,int]:
@ -99,7 +99,7 @@ class TTkDnD():
:rtype: tuple[int,int]
'''
return self._hotSpot
class TTkDnDEvent(TTkDnD):
'''
Drag and Drop event class.
@ -122,7 +122,7 @@ class TTkDnDEvent(TTkDnD):
:rtype: tuple[int,int]
'''
return self._pos
class TTkDrag(TTkDnD):
__slots__ = ('_pixmap', '_showPixmap')
def __init__(self, **kwargs) -> None:
@ -183,7 +183,7 @@ class TTkDrag(TTkDnD):
Starts the drag operation.
'''
TTkHelper.dndInit(self)
def _toDropEvent(self, pos:tuple[int,int]) -> TTkDnDEvent:
ret = TTkDnDEvent(data=self._data, hotspot=self._hotSpot, pos=pos)
return ret
@ -232,6 +232,6 @@ class TTkDrag(TTkDnD):
:type evt: :py:class:`TTkMouseEvent`
:return: The Drag and Drop event
:rtype: :py:class:`TTkDnDEvent`
:rtype: :py:class:`TTkDnDEvent`
'''
return self._toDropEvent((evt.x, evt.y))

4
TermTk/TTkGui/textcursor.py

@ -221,7 +221,7 @@ class TTkTextCursor():
def position(self) -> _CP:
return self._properties[self._cID].position
def cursors(self) -> list[_CP]:
return self._properties
@ -601,7 +601,7 @@ class TTkTextCursor():
if len(self._properties)>1:
for p in self._properties:
cp = p.position
if not 0<=(cp.line-fr)<len(ret): continue
if not 0<=(cp.line-fr)<len(ret): continue
ret[cp.line-fr] = ret[cp.line-fr].setColor(color=color+TTkColor.BLINKING, posFrom=cp.pos, posTo=cp.pos+1)
if cp.pos == len(ret[cp.line-fr]):
ret[cp.line-fr] = ret[cp.line-fr]+TTkString('',color+TTkColor.BLINKING)

2
TermTk/TTkTestWidgets/testabstractscroll.py

@ -61,7 +61,7 @@ class TTkTestAbstractScrollWidget(TTkAbstractScrollView):
def mousePressEvent(self, evt:TTkMouseEvent) -> bool:
return True
def mouseReleaseEvent(self, evt:TTkMouseEvent) -> bool:
return True

6
TermTk/TTkWidgets/combobox.py

@ -43,7 +43,7 @@ from TermTk.TTkWidgets.resizableframe import TTkResizableFrame
class _TTkComboBoxPopup(TTkResizableFrame):
classStyle = TTkResizableFrame.classStyle
classStyle['default'] |= {'searchColor': TTkColor.fg("#FFFF00")}
__slots__ = ('_list',
#exportedMethods
'setCurrentRow',
@ -57,13 +57,13 @@ class _TTkComboBoxPopup(TTkResizableFrame):
self.textClicked = self._list.textClicked
self.setCurrentRow = self._list.setCurrentRow
# def setFocus(self) -> None:
# self._list.viewport().setFocus()
def keyEvent(self, evt:TTkKeyEvent) -> bool:
return self._list.viewport().keyEvent(evt)
def paintEvent(self, canvas:TTkCanvas) -> None:
super().paintEvent(canvas)
if text := self._list.search():

28
TermTk/TTkWidgets/listwidget.py

@ -100,7 +100,7 @@ class TTkAbstractListItem(TTkWidget):
if self._highlighted == highlighted: return
self._highlighted = highlighted
self.update()
def geometry(self):
if self._quickVisible:
return super().geometry()
@ -115,9 +115,9 @@ class TTkAbstractListItem(TTkWidget):
color = color+self.style()['selected']['color']
if style==self.style()['hover']:
color = color+self.style()['hover']['color']
w = self.width()
canvas.drawTTkString(pos=(0,0), width=w, color=color ,text=self._text)
class TTkListWidget(TTkAbstractScrollView):
@ -256,14 +256,14 @@ class TTkListWidget(TTkAbstractScrollView):
self._highlighted = label
self.itemClicked.emit(label)
self.textClicked.emit(label.text())
@pyTTkSlot(str)
def _searchModifiedHandler(self, text:str='s') -> None:
if self._searchVisibility and self._searchText:
self.setPadding(1,0,0,0)
else:
self.setPadding(0,0,0,0)
if self._searchText:
text = self._searchText.lower()
self._filteredItems = [i for i in self._items if text in i._lowerText]
@ -273,13 +273,13 @@ class TTkListWidget(TTkAbstractScrollView):
self._filteredItems = self._items
for item in self._items:
item.setVisible(True)
self._placeItems()
def search(self) -> str:
'''search'''
return self._searchText
def setSearch(self, search:str) -> None:
'''setSearch'''
self._searchText = search
@ -288,7 +288,7 @@ class TTkListWidget(TTkAbstractScrollView):
def searchVisibility(self) -> bool:
'''searchVisibility'''
return self._searchVisibility
def setSearchVisibility(self, visibility:bool) -> None:
'''setSearchVisibility'''
self._searchVisibility = visibility
@ -521,17 +521,17 @@ class TTkListWidget(TTkAbstractScrollView):
if self._highlighted:
# TTkLog.debug(self._highlighted)
self._highlighted.listItemClicked.emit(self._highlighted)
elif evt.type == TTkK.Character:
# Add this char to the search text
self._searchText += evt.key
self.update()
self.searchModified.emit(self._searchText)
elif ( evt.type == TTkK.SpecialKey and
elif ( evt.type == TTkK.SpecialKey and
evt.key == TTkK.Key_Tab ):
return False
elif ( evt.type == TTkK.SpecialKey and
evt.key in (TTkK.Key_Delete,TTkK.Key_Backspace) and
self._searchText ):
@ -603,7 +603,7 @@ class TTkListWidget(TTkAbstractScrollView):
p2 = (0,y-offy)
canvas.drawText(pos=p1,text="╙─╼", color=TTkColor.fg("#FFFF00")+TTkColor.bg("#008855"))
canvas.drawText(pos=p2,text="╓─╼", color=TTkColor.fg("#FFFF00")+TTkColor.bg("#008855"))
def paintEvent(self, canvas):
if self._searchVisibility and self._searchText:
w,h = self.size()

2
TermTk/TTkWidgets/widget.py

@ -437,7 +437,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents):
self.dragMoveEvent(TTkHelper.dndGetDrag().getDragMoveEvent(evt))
return True
else:
if ( self.dragEnterEvent(TTkHelper.dndGetDrag().getDragEnterEvent(evt)) or
if ( self.dragEnterEvent(TTkHelper.dndGetDrag().getDragEnterEvent(evt)) or
self.dragMoveEvent(TTkHelper.dndGetDrag().getDragMoveEvent(evt))):
if dndw:
ret = dndw.dragLeaveEvent(TTkHelper.dndGetDrag().getDragLeaveEvent(evt))

6
docs/MDNotes/DumbPaintTool.TODO.md

@ -1,11 +1,11 @@
- [x] Save to open or last open/saved filename
- [ ] Ask to Save on quit
- [ ] Fix CanvasLayer Sizes on Save
- [ ] Fix CanvasLayer Sizes on Save
- [x] Brush colors applied back to Palette
- [x] Fix multiple layers added linked together
- AppTemplate
- AppTemplate
- [ ] Title, show the bar
- [ ] Add Title in the menuBar if available
- [ ] Tabs
- Tree
- [x] Expose resize
- [x] Expose resize

2
docs/MDNotes/Fonts/Font2Glyph.md

@ -17,7 +17,7 @@ You can use this command:
Check the font rendering in the browser:
https://typezebra.com
OK:
OK:
* FreeSans Regular
* FreeSerif Regular
* FreeMono Regular

2
docs/MDNotes/input/abstracrt.md

@ -21,7 +21,7 @@ TTkInputDriver TTkInput T
yield inString --> for inString in _readInput.read()
kevt,mevt,paste = key_process(inString)
queue.put(kevt,mevt,paste)
queue.get()
inputEvent.emit(kevt, mevt) ------> _processInput
pasteEvent.emit(str) ------> _pasteInput

4
docs/MDNotes/msWindows/Init Sequence.md

@ -3,7 +3,7 @@ TTk:
- __init__()
```python
self._input = TTkInput()
self._input.inputEvent.connect(self._processInput)
self._input.inputEvent.connect(self._processInput)
self._input.pasteEvent.connect(self._processPaste)
```
- mainLoop()
@ -15,7 +15,7 @@ TTk:
mouse=self._termMouse,
directMouse=self._termDirectMouse )
```
# How it Should Be
- __init__()
```python

2
docs/MDNotes/terminal/escape.screen.md

@ -1,4 +1,4 @@
Gnu Screen Escape
Gnu Screen Escape
https://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html
The following is a list of control sequences recognized by `screen`. ‘(V)’ and ‘(A)’ indicate VT100-specific and ANSI- or ISO-specific functions, respectively.

2
docs/MDNotes/terminal/xterm.ctrlseq.md

@ -1,7 +1,7 @@
https://www.x.org/docs/xterm/
# DCS - ESC P
ESC P + Pt + ESC \
ESC P + Pt + ESC \
Device Control String (DCS) xterm implements no DCS functions; Pt is ignored. Pt need not be printable characters.
vim initialization using DCS

28
docs/source/info/resources/dragdrop.rst

@ -4,17 +4,17 @@
Drag and Drop
=============
Drag and drop provides a simple visual mechanism which users can use to transfer
information between and within widgets.
Drag and drop provides a simple visual mechanism which users can use to transfer
information between and within widgets.
Drag and drop is similar in function to the clipboard's cut and paste mechanism.
.. image:: https://github.com/user-attachments/assets/857fd144-7a2a-4173-80b3-d135e62b8235
This document describes the basic drag and drop mechanism and outlines the
approach used to enable it in custom controls.
Drag and drop operations are also supported by many of TermTk's controls,
This document describes the basic drag and drop mechanism and outlines the
approach used to enable it in custom controls.
Drag and drop operations are also supported by many of TermTk's controls,
such as :py:class:`TTkList` or :py:class:`TTkTabWidget`.
@ -38,10 +38,10 @@ These classes deal with drag and drop and the necessary mime type encoding and d
Dragging
--------
To start a drag, create a :py:class:`TTkDrag` object, and call its :py:meth:`TTkDrag.exec` function.
In most applications, it is a good idea to begin a drag and drop operation only
after a mouse button has been pressed and the cursor has been moved a certain distance.
However, the simplest way to enable dragging from a widget is to reimplement
To start a drag, create a :py:class:`TTkDrag` object, and call its :py:meth:`TTkDrag.exec` function.
In most applications, it is a good idea to begin a drag and drop operation only
after a mouse button has been pressed and the cursor has been moved a certain distance.
However, the simplest way to enable dragging from a widget is to reimplement
the widget's :py:meth:`TTkWidget.mouseDragEvent` and start a drag and drop operation:
.. code:: python
@ -63,7 +63,7 @@ Note that the :py:meth:`TTkDrag.exec` function does not block the main event loo
Dropping
--------
To be able to receive the content dropped on a widget, reimplement
To be able to receive the content dropped on a widget, reimplement
the :py:meth:`TDragEvents.dropEvent` event handler functions.
.. code:: python
@ -117,8 +117,8 @@ Pixmap
------
The visual representation of the drag can be customized by setting a pixmap with :py:meth:`TTkDrag.setPixmap`.
By default the pixmap is initialized as a simple text string ("[...]")
but it can be customized by using
By default the pixmap is initialized as a simple text string ("[...]")
but it can be customized by using
a :py:class:`TTkWidget` or :py:class:`TTkCanvas` as a pixmap.
.. image:: https://github.com/user-attachments/assets/7a23f5a9-444b-4e5a-878b-91c4b35ee8d8
@ -175,8 +175,8 @@ HotSpot
-------
The hotspot is the offset of the pixmap related to the cursor position.
It can be set using :py:meth:`TTkDrag.setHotSpot`.
It is useful when the pixmap is not centered on the cursor or when you want to define an offset to allow
It can be set using :py:meth:`TTkDrag.setHotSpot`.
It is useful when the pixmap is not centered on the cursor or when you want to define an offset to allow
the object being dragged from the clicked position:
.. image:: https://github.com/user-attachments/assets/8d999365-c787-4eff-84f2-03ef2b22c37a

12
docs/source/sphinx_modules/sandbox_links.py

@ -29,10 +29,10 @@ def demo_link_role_int(name, rawtext, text, lineno, inliner, options={}, content
base_github_url = "https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/"
# Split text into prefix and actual file path
file_name = text.split(',')[-1].strip()
file_path = '/'.join([s.strip() for s in text.split(',')])
# Generate GitHub and TryItOnline links
github_url = f"{base_github_url}{file_path.strip()}"
@ -53,10 +53,10 @@ def demo_link_role_int_sb(name, rawtext, text, lineno, inliner, options={}, cont
base_tio_url = "https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html?filePath="
# Split text into prefix and actual file path
file_name = text.split(',')[-1].strip()
file_path = '/'.join([s.strip() for s in text.split(',')])
# Generate GitHub and TryItOnline links
github_url = f"{base_github_url}{file_path.strip()}"
tio_url = f"{base_tio_url}{file_path.strip()}"
@ -82,10 +82,10 @@ def demo_link_role_ext_sb(name, rawtext, text, lineno, inliner, options={}, cont
base_tio_url = "https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html?fileUri="
# Split text into prefix and actual file path
file_name = text.split(',')[-1].strip()
file_uri = '/'.join([s.strip() for s in text.split(',')])
# Generate GitHub and TryItOnline links
tio_url = f"{base_tio_url}{file_uri.strip()}"

2
docs/sphynx.001.signal.patch

@ -1,7 +1,7 @@
--- .venv/lib/python3.11/site-packages/sphinx/domains/python/__init__.py.old 2024-10-23 10:51:56.882646206 +0100
+++ .venv/lib/python3.11/site-packages/sphinx/domains/python/__init__.py 2024-10-23 10:53:16.557626613 +0100
@@ -204,6 +204,7 @@
option_spec: ClassVar[OptionSpec] = PyObject.option_spec.copy()
option_spec.update({
+ 'signal': directives.flag,

2
multiplexers/workbench/eumigo.txt

@ -30,7 +30,7 @@
🭋██🭥██🭐 🭢🭕█🭌🬿
🭇🬼 🭇 __X__ 🬼 🬼 X
🭇🬼 🭇 __X__ 🬼 🬼 X
🭃🭌🬿 🭃 🭌🬿 🭌 🬿 X
🭥🭒█🭏🬼 🭥🭒 🭏🬼 🭏 🬼 X
🭋🭍🭑🬽🭢🭕█🭌🬿 🭋🭍🭑🬽 🭢🭕 🭌🬿 🭌 🬿 X

4
tests/t.draw/test.draw.009.colorMix.py

@ -60,9 +60,9 @@ m1 = bg_b + fg_g
m2 = bg_b | fg_g
testColor("T2 ",m1,m2)
m3 = ttk.TTkColor.FG_YELLOW + m1
m3 = ttk.TTkColor.FG_YELLOW + m1
m4 = m1 + ttk.TTkColor.FG_YELLOW
m5 = ttk.TTkColor.FG_YELLOW | m1
m5 = ttk.TTkColor.FG_YELLOW | m1
m6 = m1 | ttk.TTkColor.FG_YELLOW
testColor("M1 ",m3,m4)
testColor("M1 ",m5,m6)

2
tests/t.generic/test.asyncio.001.multi.loop.py

@ -41,7 +41,7 @@ async def main():
# Create and run tasks for the loops
task1 = asyncio.create_task(loop_one())
task2 = asyncio.create_task(loop_two())
# Keep the program running indefinitely
await asyncio.gather(task1, task2)

16
tests/t.ui/test.ui.018.TextEdit.04.Pygments.py

@ -92,7 +92,7 @@ def demoTextEdit(root, filename):
te.setWordWrapMode(ttk.TTkK.WordWrap)
else:
te.setWordWrapMode(ttk.TTkK.WrapAnywhere)
@ttk.pyTTkSlot(ttk.TTkTextCursor)
def _positionChanged(cursor:ttk.TTkTextCursor):
extra_selections = []
@ -109,8 +109,8 @@ def demoTextEdit(root, filename):
for x in set(lines):
cursor.addCursor(x,0)
selection = ttk.TTkTextEdit.ExtraSelection(
cursor=cursor,
color=ttk.TTkColor.BG_YELLOW,
cursor=cursor,
color=ttk.TTkColor.BG_YELLOW,
format=ttk.TTkK.SelectionFormat.FullWidthSelection)
extra_selections.append(selection)
@ -118,8 +118,8 @@ def demoTextEdit(root, filename):
cursor = te.textCursor().copy()
cursor.clearSelection()
selection = ttk.TTkTextEdit.ExtraSelection(
cursor=cursor,
color=ttk.TTkColor.BG_RED,
cursor=cursor,
color=ttk.TTkColor.BG_RED,
format=ttk.TTkK.SelectionFormat.FullWidthSelection)
extra_selections.append(selection)
@ -127,11 +127,11 @@ def demoTextEdit(root, filename):
cursor = te.textCursor().copy()
cursor.select(ttk.TTkTextCursor.SelectionType.WordUnderCursor)
selection = ttk.TTkTextEdit.ExtraSelection(
cursor=cursor,
cursor=cursor,
color=ttk.TTkColor.BG_GREEN)
extra_selections.append(selection)
te.setExtraSelections(extra_selections)
te.setExtraSelections(extra_selections)
wordWrap.currentIndexChanged.connect(_wordWrapCallback)
te.cursorPositionChanged.connect(_positionChanged)
@ -164,7 +164,7 @@ def main():
for file in args.filename:
_openFile(file)
fileTree.fileActivated.connect(lambda x: _openFile(x.path()))
root.mainloop()

40
tools/webExporter/eumigo.Ansi.txt

@ -1,24 +1,24 @@
 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄🬿
 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄🬿
  █ ▃▃▃▃▃ █ 🭢🭕🭏🬼
 ▐  █ █ █ █ 🭥🭌
 ▗▘▀▀▄ ▐  █ █▄▄▄█ █ 
 ▀▖▜▝ ▐  █▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃█ 
 ▄▟▝▟▄▄▟▙▄▙▗▄▄ 
 ▗▄▄▀▙▄▀▀▀▀▀▀▄▄▄▄▄▖▙▖ 
 ▟▄▄▄▄▛▚▄▄▟▙▙▙▞▜▌▛▛▘▄▌ 
 ▐▐▐▀▀▘▟▐▝▀▀▀▀▘▙▞▀▛▛ 
 ▌▐▀▀▀▌▐▝▀▀▀▀▀▀▘▌▀▛ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  
 ▐▝▀▀▀▌▜▀▀▀▀▀▀▀▛▌▛▌  ▀▄ █ ██ █ ▖ █ █ ▝▀▀▄ ██   
 ▖▚▐▐▙▝▀▀▀▀▀▀▀▌▗▌▙  ▗▛█ ██ █ █ █ ▗▄█ █▀▀█ ██   
 ▝▖▐▐▐▙▝▐▄▄▄▄▌▙▟▙▙▙ ▝▘ █ ██ ▝▀▝▀▀ ▀▀ ▀ ▀▀ ██   
 ▝▖▐▐▐▙▐▐▟▄▄▌▐▌▌▌▌▝ ██ ██   
 ▗▄▟▀▀▌▐▐▐▐▙▝▐▄▌▌▟▌▌▌▌▐ ████████ ███████   
 ▟▀▀▀▀▀▀▖▐▐▐▐▌▐▗▌▌▐▌▌▌▌▌   
 ▗▘▀▀▄ ▐  █ █▄▄▄█ █ 
 ▀▖▜▝ ▐  █▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃█ 
 ▄▟▝▟▄▄▟▙▄▙▗▄▄ 
 ▗▄▄▀▙▄▀▀▀▀▀▀▄▄▄▄▄▖▙▖ 
 ▟▄▄▄▄▛▚▄▄▟▙▙▙▞▜▌▛▛▘▄▌ 
 ▐▐▐▀▀▘▟▐▝▀▀▀▀▘▙▞▀▛▛ 
 ▌▐▀▀▀▌▐▝▀▀▀▀▀▀▘▌▀▛ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  
 ▐▝▀▀▀▌▜▀▀▀▀▀▀▀▛▌▛▌  ▀▄ █ ██ █ ▖ █ █ ▝▀▀▄ ██   
 ▖▚▐▐▙▝▀▀▀▀▀▀▀▌▗▌▙  ▗▛█ ██ █ █ █ ▗▄█ █▀▀█ ██   
 ▝▖▐▐▐▙▝▐▄▄▄▄▌▙▟▙▙▙ ▝▘ █ ██ ▝▀▝▀▀ ▀▀ ▀ ▀▀ ██   
 ▝▖▐▐▐▙▐▐▟▄▄▌▐▌▌▌▌▝ ██ ██   
 ▗▄▟▀▀▌▐▐▐▐▙▝▐▄▌▌▟▌▌▌▌▐ ████████ ███████   
 ▟▀▀▀▀▀▀▖▐▐▐▐▌▐▗▌▌▐▌▌▌▌▌   
▐▌▌▌▌▌▛▀▌▐▐▐▐▌▐▐▌▌▜▌▌▌▌▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▝▜▙▖▌▌▌▌▙▌▐▐▐▜▐▐▙▌▐▌▌▌▌▌▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▝▜▄▄▄▄▄▌▐▐▜▀▐▐▄▌▐▛▌▌▌▙ █◢◤▗▄ ▄ ▄
▀▄▄▄▖▌▐▐▀▛▐▐▀▌▀▌▌▌▌▐▖ █◤ ▗█▖□ ▄▀▄
▀▄▄▙▖▜▀▌▐▀▀▘▀▀▀▀▗▟▘
▝▀▙▄▄▄▄▄▀▄▄▄▄▛▀
▝▜▙▖▌▌▌▌▙▌▐▐▐▜▐▐▙▌▐▌▌▌▌▌▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▝▜▄▄▄▄▄▌▐▐▜▀▐▐▄▌▐▛▌▌▌▙ █◢◤▗▄ ▄ ▄
▀▄▄▄▖▌▐▐▀▛▐▐▀▌▀▌▌▌▌▐▖ █◤ ▗█▖□ ▄▀▄
▀▄▄▙▖▜▀▌▐▀▀▘▀▀▀▀▗▟▘
▝▀▙▄▄▄▄▄▀▄▄▄▄▛▀


6
tutorial/examples/DragAndDrop/dnd.01.basic.py

@ -38,7 +38,7 @@ import TermTk as ttk
# Overriding any of those methods in a subclass will allow the widget to handle the DnD events
#
# To start a Drag and Drop operation, the TTkDrag object must be created and executed.
# The Drag and Drop operation is usually started after a mouseDragEvent as shown in
# The Drag and Drop operation is usually started after a mouseDragEvent as shown in
# this example, but it can be started after any other events/methods or signals.
class DragDrop(ttk.TTkFrame):
@ -57,9 +57,9 @@ class DragDrop(ttk.TTkFrame):
return True
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1
# +----------------+----------------+
# Row 0 | DragDrop 1 | DragDrop 2 |

6
tutorial/examples/DragAndDrop/dnd.02.events.01.py

@ -38,7 +38,7 @@ import TermTk as ttk
# Overriding any of those methods in a subclass will allow the widget to handle the DnD events
#
# To start a Drag and Drop operation, the TTkDrag object must be created and executed.
# The Drag and Drop operation is usually started after a mouseDragEvent as shown in
# The Drag and Drop operation is usually started after a mouseDragEvent as shown in
# this example, but it can be started after any other events/methods or signals.
class DragDrop(ttk.TTkFrame):
@ -69,9 +69,9 @@ class DragDrop(ttk.TTkFrame):
return True
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1
# +----------------+----------------+
# Row 0 | DragDrop 1 | DragDrop 2 |

18
tutorial/examples/DragAndDrop/dnd.02.events.02.py

@ -38,11 +38,11 @@ import TermTk as ttk
# Overriding any of those methods in a subclass will allow the widget to handle the DnD events
#
# To start a Drag and Drop operation, the TTkDrag object must be created and executed.
# The Drag and Drop operation is usually started after a mouseDragEvent as shown in
# The Drag and Drop operation is usually started after a mouseDragEvent as shown in
# this example, but it can be started after any other events/methods or signals.
#
# Here I am exploring the different interactions between the Drag and Drop events
# In particular I am testing the dragLeaveEvent whch is triggered only if the
# In particular I am testing the dragLeaveEvent whch is triggered only if the
# dragMoveEvent or dragEnterEvent has been handled (returned True) before.
class DragDrop(ttk.TTkFrame):
@ -81,17 +81,17 @@ class DragDropLeave1(DragDrop):
def dragEnterEvent(self, evt:ttk.TTkDnDEvent) -> bool:
ttk.TTkLog.debug(f"Drag Enter ({self.title()}) - {evt.data()}, pos={evt.pos()}")
return True
def dragLeaveEvent(self, evt:ttk.TTkDnDEvent) -> bool:
ttk.TTkLog.debug(f"Drag Leave ({self.title()}) - {evt.data()}, pos={evt.pos()}")
return True
class DragDropLeave2(DragDrop):
# Drag and Drop widget that handles the dragMoveEvent and dragLeaveEvent
def dragMoveEvent(self, evt:ttk.TTkDnDEvent) -> bool:
ttk.TTkLog.debug(f"Drag Move ({self.title()}) - {evt.data()}, pos={evt.pos()}")
return True
return True
def dragLeaveEvent(self, evt:ttk.TTkDnDEvent) -> bool:
ttk.TTkLog.debug(f"Drag Leave ({self.title()}) - {evt.data()}, pos={evt.pos()}")
return True
@ -99,16 +99,16 @@ class DragDropLeave2(DragDrop):
class DragDropLeave3(DragDrop):
# Drag and Drop widget that handles only the dragLeaveEvent
# NOTE:
# This widget will never receive the dragLeaveEvent because
# This widget will never receive the dragLeaveEvent because
# neither the dragMoveEvent or dragEnterEvent are handled
def dragLeaveEvent(self, evt:ttk.TTkDnDEvent) -> bool:
ttk.TTkLog.debug(f"Drag Leave ({self.title()}) - {evt.data()}, pos={evt.pos()}")
return True
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1 Col 2
# +----------------+----------------+-----------------+
# Row 0 | DnD Move | DnD Enter |

6
tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py

@ -37,7 +37,7 @@ import TermTk as ttk
class DragDrop(ttk.TTkFrame):
def mouseDragEvent(self, evt:ttk. TTkMouseEvent) -> bool:
if evt.key == ttk. TTkMouseEvent.LeftButton:
# Create a new drag object and
# Create a new drag object and
# a new TTkButton as DnD Data and Pixmap
# the default TTkButton canvas will be used as Pixmap
button = ttk.TTkButton(text=f"Test DnD ({self.title()})", border=True, size=(20,3))
@ -60,9 +60,9 @@ class DragDrop(ttk.TTkFrame):
return True
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1
# +----------------+----------------+
# Row 0 | DragDrop 1 | DragDrop 2 |

18
tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py

@ -36,11 +36,11 @@ import TermTk as ttk
class DragDrop(ttk.TTkFrame):
def mouseDragEvent(self, evt:ttk. TTkMouseEvent) -> bool:
# Create a new drag object, a new TTkLabel as DnD Data and
# Create a new drag object, a new TTkLabel as DnD Data and
# a custom Pixmap drawn as a titled box of fixed sizes around
# a snippet of the label's text
label = ttk.TTkLabel(text="Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut\nlabore et dolore magna aliqua.", size=(10,1))
pixmap = ttk.TTkCanvas(width=17,height=5)
pixmap.drawText(pos=(0,0),text="╭───────────────╮")
pixmap.drawText(pos=(2,0),text=f"{self.title()}") # Here for simplicity I am writing the title over the top border
@ -49,7 +49,7 @@ class DragDrop(ttk.TTkFrame):
pixmap.drawText(pos=(0,3),text="│sed do eiusmod │")
pixmap.drawText(pos=(0,4),text="╰───────────────╯")
# The next condition is meant to show that you can
# The next condition is meant to show that you can
# handle also the Drag and Drop with the Right or Middle mouse buttons.
if evt.key == ttk. TTkMouseEvent.LeftButton:
pixmap.drawText(pos=(0,4),text="╰───────╼ Left ╾╯")
@ -70,11 +70,11 @@ class DragDrop(ttk.TTkFrame):
# Similar to the previous example
# I am retrieving the TTkLabel widget used as Drag'nDrop data
# and I am placing it inside the current Frame
# This time I am not removing the padding sizes from the
# position due to the frame I draw in the pixmap that
# already changed the offset of the text being aligned to the final
# This time I am not removing the padding sizes from the
# position due to the frame I draw in the pixmap that
# already changed the offset of the text being aligned to the final
# dropped Label position.
# BTW, I am not a genious that can figure out all of this upfront,
# BTW, I am not a genious that can figure out all of this upfront,
# this is just the result of trial and errors
label:ttk.TTkLabel = evt.data()
self.layout().addWidget(label)
@ -83,9 +83,9 @@ class DragDrop(ttk.TTkFrame):
return True
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1
# +----------------+----------------+
# Row 0 | DragDrop 1 | DragDrop 2 |

6
tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py

@ -71,7 +71,7 @@ class DragDrop(ttk.TTkFrame):
def mouseDragEvent(self, evt:ttk. TTkMouseEvent) -> bool:
if evt.key == ttk. TTkMouseEvent.LeftButton:
# Create a new drag object and
# Create a new drag object and
# a random image is chosen
imageString = random.choice([diamond,fire,key,peach,ring,sword,whip,pepper,python])
@ -107,9 +107,9 @@ class DragDrop(ttk.TTkFrame):
super().paintEvent(canvas)
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1
# +----------------+----------------+
# Row 0 | DragDrop 1 | DragDrop 2 |

4
tutorial/examples/DragAndDrop/dnd.03.pixmap.04.py

@ -77,7 +77,7 @@ class DragDropTxt(ttk.TTkFrame):
pixmap.drawText(pos=(0,2),text="│consectetur adi│")
pixmap.drawText(pos=(0,3),text="│sed do eiusmod │")
# The next condition is meant to show that you can
# The next condition is meant to show that you can
# handle also the Drag and Drop with the Right or Middle mouse buttons.
if evt.key == ttk. TTkMouseEvent.LeftButton:
pixmap.drawText(pos=(0,4),text="╰───────╼ Left ╾╯")
@ -110,7 +110,7 @@ class DragDropImg(ttk.TTkFrame):
return True
root = ttk.TTk()
root.layout().addWidget(DragDropBase( pos=( 0, 0), size=(25,10), title="Pixmap: Default"))
root.layout().addWidget(DragDropWidget(pos=( 0, 10), size=(25,10), title="Pixmap: Widget"))
root.layout().addWidget(DragDropTxt( pos=(50, 0), size=(25,10), title="Pixmap: Txt"))

8
tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py

@ -79,19 +79,19 @@ class DropFrame(ttk.TTkFrame):
ttk.TTkLog.debug(f"Drop ({self.title()}) <- {button.text()}, pos={evt.x},{evt.y}")
# This is not required in this example
#
#
# But I just add a logging feedback to the button
# To show that the button has been clicked
# Note: I highly recommend to avoid using lambda as a slot
# The correct way is to have a method in the class, marked as pyTTkSlot,
# capable of handling the signal
button.clicked.connect(lambda: ttk.TTkLog.debug(f"Clicked: {button.text()}"))
return True
return True
# Create the root application
# and set its layout to TTkGridLayout in order to
# and set its layout to TTkGridLayout in order to
# place the widgets in the following way:
#
#
# Col 0 Col 1
# +----------------+----------------+
# Row 0 | DragDrop 1 | DragDrop 2 |

Loading…
Cancel
Save