Browse Source

Added few TTkTable examples

pull/272/head
Eugenio Parodi 1 year ago
parent
commit
c6ca329dc5
  1. 21
      TermTk/TTkWidgets/TTkModelView/tablewidget.py
  2. 15
      tutorial/examples/TTkTable/table.03.theming.color.01.py
  3. 89
      tutorial/examples/TTkTable/table.03.theming.color.02.py
  4. 149
      tutorial/examples/TTkTable/table.03.theming.color.03.py
  5. 95
      tutorial/examples/TTkTable/table.03.theming.headers.01.py
  6. 95
      tutorial/examples/TTkTable/table.03.theming.lines.01.py

21
TermTk/TTkWidgets/TTkModelView/tablewidget.py

@ -47,9 +47,9 @@ class TTkHeaderView():
This is a placeholder for a proper "TTkHeaderView"
'''
__slots__ = ('_visible','visibilityUpdated')
def __init__(self) -> None:
def __init__(self, visible=True) -> None:
self.visibilityUpdated = pyTTkSignal(bool)
self._visible = True
self._visible = visible
@pyTTkSlot(bool)
def setVisible(self, visible: bool) -> None:
@ -153,12 +153,18 @@ class TTkTableWidget(TTkAbstractScrollView):
:param tableModel: the model for the view to present.
:type tableModel: :class:`~TermTk.TTkAbstract.abstracttablemodel.TTkAbstractTableModel`
:param vSeparator: show the vertical separators, defaults to 1
:param vSeparator: show the vertical separators, defaults to True
:type vSeparator: bool, optional
:param hSeparator: show the horizontal separators, defaults to True
:type hSeparator: bool, optional
:param vHeader: show the vertical header, defaults to True
:type vHeader: bool, optional
:param hHeader: show the horizontal header, defaults to True
:type hHeader: bool, optional
:param sortingEnabled: enable the column sorting, defaults to False
:type sortingEnabled: bool, optional
@ -248,6 +254,7 @@ class TTkTableWidget(TTkAbstractScrollView):
'selectedColor': TTkColor.fg("#888888"),
'separatorColor': TTkColor.fg("#888888")},
}
'''default style'''
__slots__ = ( '_tableModel',
'_clipboard',
@ -275,6 +282,7 @@ class TTkTableWidget(TTkAbstractScrollView):
def __init__(self, *,
tableModel:TTkAbstractTableModel=None,
vSeparator:bool=True, hSeparator:bool=True,
vHeader:bool=True, hHeader:bool=True,
sortingEnabled=False, dataPadding=1,
**kwargs) -> None:
# Signals
@ -304,8 +312,8 @@ class TTkTableWidget(TTkAbstractScrollView):
self._sortingEnabled = sortingEnabled
self._showHSeparators = vSeparator
self._showVSeparators = hSeparator
self._verticalHeader = TTkHeaderView()
self._horizontallHeader = TTkHeaderView()
self._verticalHeader = TTkHeaderView(visible=vHeader)
self._horizontallHeader = TTkHeaderView(visible=hHeader)
self._selected = None
self._selectedBase = None
self._hoverPos = None
@ -317,6 +325,7 @@ class TTkTableWidget(TTkAbstractScrollView):
self._sortColumn = -1
self._sortOrder = TTkK.AscendingOrder
self._tableModel = tableModel if tableModel else TTkTableModelList(list=[['']*10 for _ in range(10)])
self._tableModel.dataChanged.connect(self.update)
super().__init__(**kwargs)
self._refreshLayout()
self.setMinimumHeight(1)
@ -784,7 +793,9 @@ class TTkTableWidget(TTkAbstractScrollView):
:param model:
:type model: :class:`~TermTk.TTkAbstract.abstracttablemodel.TTkAbstractTableModel`
'''
self._tableModel.dataChanged.disconnect(self.update)
self._tableModel = model
self._tableModel.dataChanged.connect(self.update)
self._refreshLayout()
self.viewChanged.emit()

15
tutorial/examples/TTkTable/table.03.theming.py → tutorial/examples/TTkTable/table.03.theming.color.01.py

@ -54,19 +54,22 @@ root = ttk.TTk(layout=ttk.TTkGridLayout(), mouseTrack=True)
dataList = [[f"{(row,col)}" for col in range(10)] for row in range(101)]
basicTableModel = ttk.TTkTableModelList(data=dataList)
tableStyle = {'default': {'color': ttk.TTkColor.bg("#000066", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.BG_BLUE))} }
# Table initialization:
# parent = root
# In this example the root terminal (TTk) has this table as the only child
# since it is using a gridlayout, the child will be resized to occupy the entire
# area available
#
# tableModel = basicTableModel
# I guess this is self explainatory
table = ttk.TTkTable(tableModel=basicTableModel)
root.layout().addWidget(table,1,0,1,2)
quitButton = ttk.TTkButton(text="QUIT", maxSize=(10,3))
root.layout().addWidget(quitButton,0,0)
#
# addStyle
# merge the new style with the default one
# this mergge is required to keep the default object theming values
# not explictly overridden (i.e. header/separators colors)
table = ttk.TTkTable(parent=root, tableModel=basicTableModel, addStyle=tableStyle)
# Adding a little touch, resizing the cols to its content
table.resizeColumnsToContents()

89
tutorial/examples/TTkTable/table.03.theming.color.02.py

@ -0,0 +1,89 @@
#!/usr/bin/env python3
# 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.
# Those 2 lines are required to use the TermTk library in the main folder
import sys, os
sys.path.append(os.path.join(sys.path[0],'../../..'))
import TermTk as ttk
# root
# The root (TTk) widget is the main element of any pyTermTk apps
# It is responsible of any terminal routine, the terminal update
# and the events forwarded to any child widgets
#
# root initialization params used:
#
# layout = GridLayout
# I am using a grid layout in order to align/resize the table
# to the root widget (the terminal area)
#
# mouseTrack = True (optional)
# I am enabling the mouseTrack because the table can handle
# the mouse move events and highlight the cells under the cursor
root = ttk.TTk(layout=ttk.TTkGridLayout(), mouseTrack=True)
# The TTkTable is the widget responsible of handling and displaying a table model
# There are several table models available, in this example I am using
# TTkTableModelList which require a simple 2d List with the table data
# I am initializing a simple list where any cell is a string representing its position (row,col) inside the list
dataList = [[f"{(row,col)}" for col in range(10)] for row in range(101)]
basicTableModel = ttk.TTkTableModelList(data=dataList)
tableStyle1 = {'default': {
'color': ttk.TTkColor.bg("#006600", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.bg("#003300"))),
'selectedColor': ttk.TTkColor.bg("#00AA00"),
'hoverColor': ttk.TTkColor.bg("#00AAAA")} }
tableStyle2 = {'default': {
'color': ttk.TTkColor.bg("#660066", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.RST)),
'lineColor': ttk.TTkColor.fg("#FFFF00"),
'headerColor': ttk.TTkColor.fg("#FFFF00")+ttk.TTkColor.bg("#660066"),
'hoverColor': ttk.TTkColor.bg("#AAAAAA"),
'selectedColor': ttk.TTkColor.bg("#FFAA66"),
'separatorColor': ttk.TTkColor.fg("#330055")+ttk.TTkColor.bg("#660066")} }
# Table initialization:
# parent = root
# In this example the root terminal (TTk) has this table as the only child
# since it is using a gridlayout, the child will be resized to occupy the entire
# area available
#
# tableModel = basicTableModel
# I guess this is self explainatory
#
# addStyle
# merge the new style with the default one
# this mergge is required to keep the default object theming values
# not explictly overridden (i.e. header/separators colors)
table1 = ttk.TTkTable(parent=root, tableModel=basicTableModel, addStyle=tableStyle1)
table2 = ttk.TTkTable(parent=root, tableModel=basicTableModel, addStyle=tableStyle2)
# Adding a little touch, resizing the cols to its content
table1.resizeColumnsToContents()
# Start the main thread
root.mainloop()

149
tutorial/examples/TTkTable/table.03.theming.color.03.py

@ -0,0 +1,149 @@
#!/usr/bin/env python3
# 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.
# Those 2 lines are required to use the TermTk library in the main folder
import sys, os
sys.path.append(os.path.join(sys.path[0],'../../..'))
import TermTk as ttk
# This is a custom color modifier used to add a color pattern on each table line
class CustomColorModifier(ttk.TTkAlternateColor):
# I am defining a list of colors used as a circle list in this class
colors = (
[ ttk.TTkColor.bg("#000066"), ttk.TTkColor.bg("#0000FF") ] * 3 +
[ ttk.TTkColor.bg("#003300"), ttk.TTkColor.bg("#006600") ] +
[ ttk.TTkColor.bg("#000066"), ttk.TTkColor.bg("#0000FF") ] * 3 +
[ttk.TTkColor.RST] * 5 +
[ #Rainbow-ish
ttk.TTkColor.fgbg("#00FFFF","#880000") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#00FFFF","#FF0000") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#0000FF","#FFFF00") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#FF00FF","#00FF00") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#FF0000","#00FFFF") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#FFFF00","#0000FF") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#00FF00","#FF00FF") + ttk.TTkColor.BOLD,
ttk.TTkColor.fgbg("#00FF00","#880088") + ttk.TTkColor.BOLD] +
[ttk.TTkColor.RST] * 3 +
[ttk.TTkColor.bg("#0000FF")] +
[ttk.TTkColor.RST] * 2 +
[ttk.TTkColor.bg("#0000FF")] +
[ttk.TTkColor.RST] +
[ttk.TTkColor.bg("#0000FF")] +
[ttk.TTkColor.RST] +
[ttk.TTkColor.bg("#0000FF")] * 2 +
[ttk.TTkColor.RST] * 3 +
[ttk.TTkColor.bg("#0000FF")] * 3 +
[ttk.TTkColor.RST] * 5 +
#Rainbow-ish 2
[ttk.TTkColor.fgbg("#00FF00","#880088")] * 2 +
[ttk.TTkColor.fgbg("#00FF00","#FF00FF")] * 2 +
[ttk.TTkColor.fgbg("#FFFF00","#0000FF")] * 2 +
[ttk.TTkColor.fgbg("#FF0000","#00FFFF")] * 2 +
[ttk.TTkColor.fgbg("#FF00FF","#00FF00")] * 2 +
[ttk.TTkColor.fgbg("#0000FF","#FFFF00")] * 2 +
[ttk.TTkColor.fgbg("#00FFFF","#FF0000")] * 2 +
[ttk.TTkColor.fgbg("#00FFFF","#880000")] * 2 +
[ttk.TTkColor.RST] * 2
)
# the exec function is called at each table line ('y')
def exec(self, x:int, y:int, base_color:ttk.TTkColor) -> ttk.TTkColor:
c = CustomColorModifier.colors
return c[y%len(c)]
# root
# The root (TTk) widget is the main element of any pyTermTk apps
# It is responsible of any terminal routine, the terminal update
# and the events forwarded to any child widgets
#
# root initialization params used:
#
# layout = GridLayout
# I am using a grid layout in order to align/resize the table
# to the root widget (the terminal area)
#
# mouseTrack = True (optional)
# I am enabling the mouseTrack because the table can handle
# the mouse move events and highlight the cells under the cursor
root = ttk.TTk(layout=ttk.TTkGridLayout(), mouseTrack=True)
# The TTkTable is the widget responsible of handling and displaying a table model
# There are several table models available, in this example I am using
# TTkTableModelList which require a simple 2d List with the table data
# I am initializing a simple list where any cell is a string representing its position (row,col) inside the list
dataList = [[f"{(row,col)}" for col in range(10)] for row in range(101)]
basicTableModel = ttk.TTkTableModelList(data=dataList)
# Custom color styles
tableStyle1 = {'default': {}}
tableStyle2 = {'default': {
'color': ttk.TTkColor.bg("#006600", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.bg("#003300"))),
'selectedColor': ttk.TTkColor.bg("#00AA00"),
'hoverColor': ttk.TTkColor.bg("#00AAAA")} }
tableStyle3 = {'default': {
'color': ttk.TTkColor.bg("#660066", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.RST))} }
tableStyle4 = {'default': {
'color': ttk.TTkColor.bg("#000000", modifier=CustomColorModifier()),
'lineColor': ttk.TTkColor.fg("#FFFF00"),
'headerColor': ttk.TTkColor.fg("#FFFF00")+ttk.TTkColor.bg("#880000"),
'hoverColor': ttk.TTkColor.bg("#AAAAAA"),
'selectedColor': ttk.TTkColor.bg("#FFAA66"),
'separatorColor': ttk.TTkColor.fg("#330055")+ttk.TTkColor.bg("#660066")} }
# Table initialization:
# parent = root
# In this example the root terminal (TTk) has this table as the only child
# since it is using a gridlayout, the child will be resized to occupy the entire
# area available
#
# tableModel = basicTableModel
# I guess this is self explainatory
#
# addStyle
# merge the new style with the default one
# this mergge is required to keep the default object theming values
# not explictly overridden (i.e. header/separators colors)
table1 = ttk.TTkTable(tableModel=basicTableModel, addStyle=tableStyle1)
table2 = ttk.TTkTable(tableModel=basicTableModel, addStyle=tableStyle2)
table3 = ttk.TTkTable(tableModel=basicTableModel, addStyle=tableStyle3)
table4 = ttk.TTkTable(tableModel=basicTableModel, addStyle=tableStyle4)
root.layout().addWidget(table1,0,0)
root.layout().addWidget(table2,0,1)
root.layout().addWidget(table3,1,0)
root.layout().addWidget(table4,1,1)
# Adding a little touch, resizing the cols to its content
table1.resizeColumnsToContents()
# Start the main thread
root.mainloop()

95
tutorial/examples/TTkTable/table.03.theming.headers.01.py

@ -0,0 +1,95 @@
#!/usr/bin/env python3
# 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.
# Those 2 lines are required to use the TermTk library in the main folder
import sys, os
sys.path.append(os.path.join(sys.path[0],'../../..'))
import TermTk as ttk
# root
# The root (TTk) widget is the main element of any pyTermTk apps
# It is responsible of any terminal routine, the terminal update
# and the events forwarded to any child widgets
#
# root initialization params used:
#
# layout = GridLayout
# I am using a grid layout in order to align/resize the table
# to the root widget (the terminal area)
#
# mouseTrack = True (optional)
# I am enabling the mouseTrack because the table can handle
# the mouse move events and highlight the cells under the cursor
root = ttk.TTk(layout=ttk.TTkGridLayout(), mouseTrack=True)
# The TTkTable is the widget responsible of handling and displaying a table model
# There are several table models available, in this example I am using
# TTkTableModelList which require a simple 2d List with the table data
# I am initializing a simple list where any cell is a string representing its position (row,col) inside the list
dataList = [[f"{(row,col)}" for col in range(10)] for row in range(101)]
basicTableModel = ttk.TTkTableModelList(data=dataList)
# Custom color styles
tableStyle2 = {'default': {'color': ttk.TTkColor.bg("#006600", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.bg("#003300")))} }
tableStyle3 = {'default': {'color': ttk.TTkColor.bg("#660066", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.RST))} }
tableStyle4 = {'default': {'color': ttk.TTkColor.bg("#660000", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.bg("#440000")))} }
# Table initialization:
# parent = root
# In this example the root terminal (TTk) has this table as the only child
# since it is using a gridlayout, the child will be resized to occupy the entire
# area available
#
# tableModel = basicTableModel
# I guess this is self explainatory
#
# addStyle
# merge the new style with the default one
# this mergge is required to keep the default object theming values
# not explictly overridden (i.e. header/separators colors)
#
# vHeader, hHeader = True/False
# display the vertical/horizontal header
table1 = ttk.TTkTable(tableModel=basicTableModel, hHeader=True, vHeader=True )
table2 = ttk.TTkTable(tableModel=basicTableModel, hHeader=False, vHeader=True, addStyle=tableStyle2)
table3 = ttk.TTkTable(tableModel=basicTableModel, hHeader=True, vHeader=False, addStyle=tableStyle3)
table4 = ttk.TTkTable(tableModel=basicTableModel, hHeader=False, vHeader=False, addStyle=tableStyle4)
root.layout().addWidget(table1,0,0)
root.layout().addWidget(table2,0,1)
root.layout().addWidget(table3,1,0)
root.layout().addWidget(table4,1,1)
# Adding a little touch, resizing the cols to its content
table1.resizeColumnsToContents()
table2.resizeColumnsToContents()
table3.resizeColumnsToContents()
table4.resizeColumnsToContents()
# Start the main thread
root.mainloop()

95
tutorial/examples/TTkTable/table.03.theming.lines.01.py

@ -0,0 +1,95 @@
#!/usr/bin/env python3
# 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.
# Those 2 lines are required to use the TermTk library in the main folder
import sys, os
sys.path.append(os.path.join(sys.path[0],'../../..'))
import TermTk as ttk
# root
# The root (TTk) widget is the main element of any pyTermTk apps
# It is responsible of any terminal routine, the terminal update
# and the events forwarded to any child widgets
#
# root initialization params used:
#
# layout = GridLayout
# I am using a grid layout in order to align/resize the table
# to the root widget (the terminal area)
#
# mouseTrack = True (optional)
# I am enabling the mouseTrack because the table can handle
# the mouse move events and highlight the cells under the cursor
root = ttk.TTk(layout=ttk.TTkGridLayout(), mouseTrack=True)
# The TTkTable is the widget responsible of handling and displaying a table model
# There are several table models available, in this example I am using
# TTkTableModelList which require a simple 2d List with the table data
# I am initializing a simple list where any cell is a string representing its position (row,col) inside the list
dataList = [[f"{(row,col)}" for col in range(10)] for row in range(101)]
basicTableModel = ttk.TTkTableModelList(data=dataList)
# Custom color styles
tableStyle2 = {'default': {'color': ttk.TTkColor.bg("#006600", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.bg("#003300")))} }
tableStyle3 = {'default': {'color': ttk.TTkColor.bg("#660066", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.RST))} }
tableStyle4 = {'default': {'color': ttk.TTkColor.bg("#660000", modifier=ttk.TTkAlternateColor(alternateColor=ttk.TTkColor.bg("#440000")))} }
# Table initialization:
# parent = root
# In this example the root terminal (TTk) has this table as the only child
# since it is using a gridlayout, the child will be resized to occupy the entire
# area available
#
# tableModel = basicTableModel
# I guess this is self explainatory
#
# addStyle
# merge the new style with the default one
# this mergge is required to keep the default object theming values
# not explictly overridden (i.e. header/separators colors)
#
# vSeparator, hSeparator = True/False
# display the vertical/horizontal line separator
table1 = ttk.TTkTable(tableModel=basicTableModel, vSeparator=True, hSeparator=True )
table2 = ttk.TTkTable(tableModel=basicTableModel, vSeparator=False, hSeparator=True, addStyle=tableStyle2)
table3 = ttk.TTkTable(tableModel=basicTableModel, vSeparator=True, hSeparator=False, addStyle=tableStyle3)
table4 = ttk.TTkTable(tableModel=basicTableModel, vSeparator=False, hSeparator=False, addStyle=tableStyle4)
root.layout().addWidget(table1,0,0)
root.layout().addWidget(table2,0,1)
root.layout().addWidget(table3,1,0)
root.layout().addWidget(table4,1,1)
# Adding a little touch, resizing the cols to its content
table1.resizeColumnsToContents()
table2.resizeColumnsToContents()
table3.resizeColumnsToContents()
table4.resizeColumnsToContents()
# Start the main thread
root.mainloop()
Loading…
Cancel
Save