Browse Source

#284 : Added TTkTree and TTkFileTreeWidget to ttkdesigner

pull/285/head
Eugenio Parodi 1 year ago
parent
commit
a6ae409598
  1. 45
      TermTk/TTkUiTools/properties/filetree.py
  2. 1
      TermTk/TTkUiTools/properties/scrollbar.py
  3. 45
      TermTk/TTkUiTools/properties/tree.py
  4. 43
      TermTk/TTkUiTools/uiproperties.py
  5. 43
      TermTk/TTkWidgets/TTkModelView/filetreewidget.py
  6. 8
      TermTk/TTkWidgets/TTkModelView/treewidget.py
  7. 6
      tools/ttkDesigner/app/widgetbox.py

45
TermTk/TTkUiTools/properties/filetree.py

@ -0,0 +1,45 @@
# MIT License
#
# Copyright (c) 2024 Eugenio Parodi <ceccopierangiolieugenio AT googlemail DOT com>
#
# 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.
__all__ = ['TTkFileTreeProperties']
from TermTk.TTkCore.constant import TTkK
from TermTk.TTkWidgets.TTkModelView.filetree import TTkFileTree
from TermTk.TTkWidgets.TTkModelView.filetreewidget import TTkFileTreeWidget
from TermTk.TTkWidgets.TTkModelView.treewidgetitem import TTkTreeWidgetItem
TTkFileTreeProperties = {
'properties' : {
'Path' : {
'init': {'name':'path', 'type':str } ,
'get': { 'cb':TTkFileTreeWidget.getOpenPath, 'type':str, 'fw_obj':TTkFileTree.viewport } ,
'set': { 'cb':TTkFileTreeWidget.openPath, 'type':str, 'fw_obj':TTkFileTree.viewport } },
},'signals' : {
'itemActivated(TTkTreeWidgetItem,int)' : {'name' : 'itemActivated' , 'type':(TTkTreeWidgetItem,int)},
'itemChanged(TTkTreeWidgetItem,int)' : {'name' : 'itemChanged' , 'type':(TTkTreeWidgetItem,int)},
'itemClicked(TTkTreeWidgetItem,int)' : {'name' : 'itemClicked' , 'type':(TTkTreeWidgetItem,int)},
'itemDoubleClicked(TTkTreeWidgetItem,int)' : {'name' : 'itemDoubleClicked' , 'type':(TTkTreeWidgetItem,int)},
'itemExpanded(TTkTreeWidgetItem)' : {'name' : 'itemExpanded' , 'type': TTkTreeWidgetItem},
'itemCollapsed(TTkTreeWidgetItem)' : {'name' : 'itemCollapsed' , 'type': TTkTreeWidgetItem},
},'slots' : {
}
}

1
TermTk/TTkUiTools/properties/scrollbar.py

@ -22,7 +22,6 @@
__all__ = ['TTkScrollBarProperties']
from TermTk.TTkCore.string import TTkString
from TermTk.TTkCore.constant import TTkK
from TermTk.TTkWidgets.scrollbar import TTkScrollBar

45
TermTk/TTkUiTools/properties/tree.py

@ -0,0 +1,45 @@
# MIT License
#
# Copyright (c) 2024 Eugenio Parodi <ceccopierangiolieugenio AT googlemail DOT com>
#
# 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.
__all__ = ['TTkTreeProperties']
from TermTk.TTkCore.constant import TTkK
from TermTk.TTkWidgets.TTkModelView.tree import TTkTree
from TermTk.TTkWidgets.TTkModelView.treewidget import TTkTreeWidget
from TermTk.TTkWidgets.TTkModelView.treewidgetitem import TTkTreeWidgetItem
TTkTreeProperties = {
'properties' : {
'Sorting' : {
'init': {'name':'sortingEnabled', 'type':bool } ,
'get': { 'cb':TTkTreeWidget.isSortingEnabled, 'type':bool, 'fw_obj':TTkTree.viewport } ,
'set': { 'cb':TTkTreeWidget.setSortingEnabled, 'type':bool, 'fw_obj':TTkTree.viewport } },
},'signals' : {
'itemActivated(TTkTreeWidgetItem,int)' : {'name' : 'itemActivated' , 'type':(TTkTreeWidgetItem,int)},
'itemChanged(TTkTreeWidgetItem,int)' : {'name' : 'itemChanged' , 'type':(TTkTreeWidgetItem,int)},
'itemClicked(TTkTreeWidgetItem,int)' : {'name' : 'itemClicked' , 'type':(TTkTreeWidgetItem,int)},
'itemDoubleClicked(TTkTreeWidgetItem,int)' : {'name' : 'itemDoubleClicked' , 'type':(TTkTreeWidgetItem,int)},
'itemExpanded(TTkTreeWidgetItem)' : {'name' : 'itemExpanded' , 'type': TTkTreeWidgetItem},
'itemCollapsed(TTkTreeWidgetItem)' : {'name' : 'itemCollapsed' , 'type': TTkTreeWidgetItem},
},'slots' : {
}
}

43
TermTk/TTkUiTools/uiproperties.py

@ -54,7 +54,8 @@ from .properties.widget import *
from .properties.window import *
from .properties.table import *
# from .properties.tree import *
from .properties.tree import *
from .properties.filetree import *
# from .properties.terminal import *
# Pickers
@ -66,28 +67,30 @@ from .properties.layout import *
TTkUiProperties = {
# Widgets
TTkButton.__name__: TTkButtonProperties,
TTkCheckbox.__name__: TTkCheckboxProperties,
TTkContainer.__name__: TTkContainerProperties,
TTkComboBox.__name__: TTkComboBoxProperties,
TTkFrame.__name__: TTkFrameProperties,
TTkLabel.__name__: TTkLabelProperties,
TTkLineEdit.__name__: TTkLineEditProperties,
TTkList.__name__: TTkListProperties,
TTkMenuButton.__name__: TTkMenuButtonProperties,
TTkRadioButton.__name__: TTkRadioButtonProperties,
TTkResizableFrame.__name__: TTkResizableFrameProperties,
TTkScrollBar.__name__: TTkScrollBarProperties,
TTkSpinBox.__name__: TTkSpinBoxProperties,
TTkSplitter.__name__: TTkSplitterProperties,
TTkTextEdit.__name__: TTkTextEditProperties,
TTkWidget.__name__: TTkWidgetProperties,
TTkWindow.__name__: TTkWindowProperties,
TTkButton.__name__ : TTkButtonProperties,
TTkCheckbox.__name__ : TTkCheckboxProperties,
TTkContainer.__name__ : TTkContainerProperties,
TTkComboBox.__name__ : TTkComboBoxProperties,
TTkFrame.__name__ : TTkFrameProperties,
TTkLabel.__name__ : TTkLabelProperties,
TTkLineEdit.__name__ : TTkLineEditProperties,
TTkList.__name__ : TTkListProperties,
TTkMenuButton.__name__ : TTkMenuButtonProperties,
TTkRadioButton.__name__ : TTkRadioButtonProperties,
TTkResizableFrame.__name__ : TTkResizableFrameProperties,
TTkScrollBar.__name__ : TTkScrollBarProperties,
TTkSpinBox.__name__ : TTkSpinBoxProperties,
TTkSplitter.__name__ : TTkSplitterProperties,
TTkTextEdit.__name__ : TTkTextEditProperties,
TTkWidget.__name__ : TTkWidgetProperties,
TTkWindow.__name__ : TTkWindowProperties,
# Pickers
TTkColorButtonPicker.__name__ : TTkColorButtonPickerProperties,
TTkFileButtonPicker.__name__ : TTkFileButtonPickerProperties,
# Layouts
TTkLayout.__name__: TTkLayoutProperties,
TTkLayout.__name__ : TTkLayoutProperties,
# Models
TTkTable.__name__: TTkTableProperties,
TTkTable.__name__ : TTkTableProperties,
TTkTree.__name__ : TTkTreeProperties,
TTkFileTree.__name__ : TTkFileTreeProperties,
}

43
TermTk/TTkWidgets/TTkModelView/filetreewidget.py

@ -77,6 +77,49 @@ class TTkFileTreeWidget(TTkTreeWidget):
root.mainloop()
'''
fileClicked:pyTTkSignal
'''
This signal is emitted when a file is clicked
:param file:
:type file: :py:class:`TTkFileTreeWidgetItem`
'''
folderClicked:pyTTkSignal
'''
This signal is emitted when a folder is clicked
:param folder:
:type folder: :py:class:`TTkFileTreeWidgetItem`
'''
fileDoubleClicked:pyTTkSignal
'''
This signal is emitted when a file is doubleclicked
:param file:
:type file: :py:class:`TTkFileTreeWidgetItem`
'''
folderDoubleClicked:pyTTkSignal
'''
This signal is emitted when a folder is doubleclicked
:param folder:
:type folder: :py:class:`TTkFileTreeWidgetItem`
'''
fileActivated:pyTTkSignal
'''
This signal is emitted when a file is activated
:param file:
:type file: :py:class:`TTkFileTreeWidgetItem`
'''
folderActivated:pyTTkSignal
'''
This signal is emitted when a fiilder is activated
:param folder:
:type folder: :py:class:`TTkFileTreeWidgetItem`
'''
__slots__ = ('_path', '_filter',
# Signals
'fileClicked', 'folderClicked', 'fileDoubleClicked', 'folderDoubleClicked', 'fileActivated', 'folderActivated')

8
TermTk/TTkWidgets/TTkModelView/treewidget.py

@ -164,6 +164,12 @@ class TTkTreeWidget(TTkAbstractScrollView):
header=[],
sortingEnabled=True,
**kwargs) -> None:
'''
:param header: define the header labels of each column, defaults to []
:type header: list[TTkString], optional
:param sortingEnabled: enable the column sorting, defaults to False
:type sortingEnabled: bool, optional
'''
# Signals
self.itemActivated = pyTTkSignal(TTkTreeWidgetItem, int)
self.itemChanged = pyTTkSignal(TTkTreeWidgetItem, int)
@ -254,7 +260,7 @@ class TTkTreeWidget(TTkAbstractScrollView):
return [self._selected]
return None
def setHeaderLabels(self, labels:str) -> None:
def setHeaderLabels(self, labels:TTkString) -> None:
'''setHeaderLabels'''
self._header = labels
# Set 20 as default column size

6
tools/ttkDesigner/app/widgetbox.py

@ -48,7 +48,7 @@ dWidgets = {
'Input Widgets':{
"ComboBox" : { "class":ttk.TTkComboBox, "params":{'size':(20,1)} },
"LineEdit" : { "class":ttk.TTkLineEdit, "params":{'size':(20,1)} },
"TextEdit" : { "class":ttk.TTkTextEdit, "params":{'size':(20,5), 'readOnly':False, 'multiline':True } },
"TextEdit" : { "class":ttk.TTkTextEdit, "params":{'size':(25,8), 'readOnly':False, 'multiline':True } },
"TextEditLine": { "class":ttk.TTkTextEdit, "params":{'size':(20,1), 'readOnly':False, 'multiLine':False, 'maxHeight':1 } },
"SpinBox" : { "class":ttk.TTkSpinBox, "params":{'size':(20,1)} },
"H ScrollBar" : { "class":ttk.TTkScrollBar, "params":{'size':(10,1), "orientation":ttk.TTkK.HORIZONTAL} },
@ -66,7 +66,9 @@ dWidgets = {
"Widget" : { "class":ttk.TTkWidget, "params":{'size':(20,5)}},
},
'Model View':{
"Table" : { "class":ttk.TTkTable, "params":{'size':( 20,5)}},
"Table" : { "class":ttk.TTkTable, "params":{'size':( 25,8)}},
"Tree" : { "class":ttk.TTkTree, "params":{'size':( 25,8)}},
"FileTree" : { "class":ttk.TTkFileTree, "params":{'size':( 25,8)}},
},
'Pickers':{
"Color Picker" : { "class":ttk.TTkColorButtonPicker, "params":{'size':( 6,3), 'border':True}},

Loading…
Cancel
Save