From d22eba93216dcb67e507e980c262e14bf0cb485e Mon Sep 17 00:00:00 2001 From: Eugenio Parodi Date: Tue, 3 Jan 2023 16:15:07 +0100 Subject: [PATCH] Removed data property --- TermTk/TTkTemplates/color.py | 42 ------------------ TermTk/TTkTemplates/data.py | 41 ------------------ TermTk/TTkTemplates/text.py | 50 ---------------------- TermTk/TTkWidgets/TTkPickers/filepicker.py | 2 +- TermTk/TTkWidgets/listwidget.py | 15 +++++-- demo/showcase/list.py | 2 +- 6 files changed, 13 insertions(+), 139 deletions(-) delete mode 100644 TermTk/TTkTemplates/color.py delete mode 100644 TermTk/TTkTemplates/data.py delete mode 100644 TermTk/TTkTemplates/text.py diff --git a/TermTk/TTkTemplates/color.py b/TermTk/TTkTemplates/color.py deleted file mode 100644 index 2b058e03..00000000 --- a/TermTk/TTkTemplates/color.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 - -# MIT License -# -# Copyright (c) 2021 Eugenio Parodi -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from TermTk.TTkCore.color import TTkColor - -class DeprecatedTColor(): - #__slots__ = ('_color') - def __init__(self, *args, **kwargs): - self._color = kwargs.get('color', TTkColor.RST ) - - def colorUpdated(self, color): pass - - @property - def color(self): - return self._color - - @color.setter - def color(self, color): - if self.color != color: - self._color = color - self.colorUpdated(color) \ No newline at end of file diff --git a/TermTk/TTkTemplates/data.py b/TermTk/TTkTemplates/data.py deleted file mode 100644 index c4c069bb..00000000 --- a/TermTk/TTkTemplates/data.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 - -# MIT License -# -# Copyright (c) 2021 Eugenio Parodi -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -class TData(): - #__slots__ = ('_data') - def __init__(self, *args, **kwargs): - self._data = kwargs.get('data', "" ) - - def dataUpdated(self, data): pass - - @property - def data(self): - return self._data - - @data.setter - def data(self, data): - if self.data != data: - self._data = data - self.dataUpdated(data) - diff --git a/TermTk/TTkTemplates/text.py b/TermTk/TTkTemplates/text.py deleted file mode 100644 index 7cd99cda..00000000 --- a/TermTk/TTkTemplates/text.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -# MIT License -# -# Copyright (c) 2021 Eugenio Parodi -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from TermTk.TTkCore.string import TTkString - -class DeprecatedTText(): - #__slots__ = ('_text') - def __init__(self, *args, **kwargs): - text = kwargs.get('text', TTkString() ) - if issubclass(type(text), TTkString): - self._text = text - else: - self._text = TTkString(text) - - def textUpdated(self, text): pass - - @property - def text(self): - return self._text - - @text.setter - def text(self, text): - if self.text != text: - if issubclass(type(text), TTkString): - self._text = text - else: - self._text = TTkString(text) - self.textUpdated(self._text) - diff --git a/TermTk/TTkWidgets/TTkPickers/filepicker.py b/TermTk/TTkWidgets/TTkPickers/filepicker.py index b830785a..7cc57c64 100644 --- a/TermTk/TTkWidgets/TTkPickers/filepicker.py +++ b/TermTk/TTkWidgets/TTkPickers/filepicker.py @@ -142,7 +142,7 @@ class TTkFileDialogPicker(TTkWindow): bookmarks.addItem(TTkString() + TTkCfg.theme.fileIconColor + TTkCfg.theme.fileIcon.computer + TTkColor.RST+" Computer", data='/') bookmarks.addItem(TTkString() + TTkCfg.theme.fileIconColor + TTkCfg.theme.fileIcon.home + TTkColor.RST+" Home", data=os.path.expanduser("~")) def _bookmarksCallback(item): - self._openNewPath(item.data) + self._openNewPath(item.data()) bookmarks.itemClicked.connect(_bookmarksCallback) # Home Folder (Win Compatible): diff --git a/TermTk/TTkWidgets/listwidget.py b/TermTk/TTkWidgets/listwidget.py index 10cfe4bf..7857f861 100644 --- a/TermTk/TTkWidgets/listwidget.py +++ b/TermTk/TTkWidgets/listwidget.py @@ -31,13 +31,12 @@ from TermTk.TTkCore.string import TTkString from TermTk.TTkWidgets.widget import TTkWidget from TermTk.TTkWidgets.label import TTkLabel from TermTk.TTkAbstract.abstractscrollview import TTkAbstractScrollView -from TermTk.TTkTemplates.data import TData -class TTkAbstractListItem(TTkLabel, TData): - __slots__ = ('_pressed', '_selected', '_highlighted', 'listItemClicked') +class TTkAbstractListItem(TTkLabel): + __slots__ = ('_pressed', '_selected', '_highlighted', 'listItemClicked', '_data') def __init__(self, *args, **kwargs): - TData.__init__(self, *args, **kwargs) TTkLabel.__init__(self, *args, **kwargs) + self._data = kwargs.get('data', "" ) # Define Signals self.listItemClicked = pyTTkSignal(TTkAbstractListItem) self._selected = False @@ -56,6 +55,14 @@ class TTkAbstractListItem(TTkLabel, TData): else: self.setColor(TTkCfg.theme.listColor) + def data(self): + return self._data + + def setData(self, data): + if self._data != data: + self._data = data + self.update() + def keyEvent(self, evt): return self.parentWidget().keyEvent(evt) diff --git a/demo/showcase/list.py b/demo/showcase/list.py index fd06b3f0..802e59aa 100755 --- a/demo/showcase/list.py +++ b/demo/showcase/list.py @@ -59,7 +59,7 @@ def demoList(root= None): @ttk.pyTTkSlot(str) def _listCallback2(label): ttk.TTkLog.info(f"Clicked label2: {label} - selected: {listWidgetMulti.selectedLabels()}") - label2.text(f"[ list2 ] {listWidgetMulti.selectedLabels()}") + label2.setText(f"[ list2 ] {[str(s) for s in listWidgetMulti.selectedLabels()]}") # Connect the signals to the 2 slots defines listWidgetSingle.textClicked.connect(_listCallback1)