10 changed files with 517 additions and 21 deletions
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2021 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. |
||||
|
||||
from TermTk.TTkCore.log import TTkLog |
||||
from TermTk.TTkCore.signal import pyTTkSlot, pyTTkSignal |
||||
from TermTk.TTkCore.color import TTkColor |
||||
from TermTk.TTkWidgets.widget import TTkWidget, TTkScrollBar, TTkLayout |
||||
|
||||
''' |
||||
|
||||
|
||||
''' |
||||
class TTkScrollArea(TTkWidget): |
||||
__slots__ = ('_border', '_hszroll', '_vscroll', '_widgetScroller') |
||||
def __init__(self, *args, **kwargs): |
||||
TTkWidget.__init__(self, *args, **kwargs) |
||||
self._name = kwargs.get('name' , 'TTkScrollArea' ) |
||||
# self._border = kwargs.get('border', True ) |
||||
# if self._border: |
||||
# self.setPadding(1,2,1,2) |
||||
# else: |
||||
# self.setPadding(0,1,0,1) |
||||
# self._hscroll = TTkScrollBar(parent=self) |
||||
# self._vscroll = TTkScrollBar(parent=self) |
||||
|
||||
#def setWidget(self, widget): |
||||
|
||||
#def setLayout(self, layout): |
||||
# self._layout = layout |
||||
# self._layout.setParent(self) |
||||
# self._layout.setGeometry( |
||||
# self._padl, self._padt, |
||||
# self._width - self._padl - self._padr, |
||||
# self._height - self._padt - self._padb) |
||||
# self.update(repaint=True, updateLayout=True) |
||||
|
||||
#def paintEvent(self): |
||||
# if self._border: |
||||
# self._canvas.drawBox(pos=(0,0),size=(self._width,self._height)) |
||||
@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2021 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. |
||||
|
||||
from TermTk.TTkCore.constant import TTkK |
||||
from TermTk.TTkCore.log import TTkLog |
||||
from TermTk.TTkCore.signal import pyTTkSlot, pyTTkSignal |
||||
from TermTk.TTkCore.color import TTkColor |
||||
from TermTk.TTkWidgets.widget import TTkWidget |
||||
from TermTk.TTkWidgets.layout import * |
||||
from TermTk.TTkWidgets.spacer import TTkSpacer |
||||
from TermTk.TTkWidgets.scrollbar import TTkScrollBar |
||||
|
||||
''' |
||||
|
||||
|
||||
''' |
||||
class TTkTable(TTkWidget): |
||||
__slots__ = ('_hlayout','_vscroller','_columns','_tableData', '_moveTo') |
||||
def __init__(self, *args, **kwargs): |
||||
self._vscroller = None # This is required to avoid crash int he vScroller Tuning |
||||
self._moveTo = 0 |
||||
self._tableData = [] |
||||
TTkWidget.__init__(self, *args, **kwargs) |
||||
self._name = kwargs.get('name' , 'TTkTable' ) |
||||
self._columns = kwargs.get('columns' , 'TTkTable' ) |
||||
self._hlayout = TTkHBoxLayout() |
||||
self.setLayout(self._hlayout) |
||||
TTkSpacer(parent=self) |
||||
self._vscroller = TTkScrollBar(parent=self) |
||||
self._vscroller.valueChanged.connect(self.scrollTo) |
||||
|
||||
def setColumnSize(self, columns): |
||||
self._columns = columns |
||||
|
||||
def appendItem(self, item): |
||||
self._tableData.append(item) |
||||
self._tuneTheScroller() |
||||
|
||||
def resizeEvent(self, w, h): |
||||
if self._moveTo > len(self._tableData)-h: |
||||
self._moveTo = len(self._tableData)-h |
||||
self._tuneTheScroller() |
||||
|
||||
def _tuneTheScroller(self): |
||||
if self._vscroller is None: return |
||||
scrollTo = len(self._tableData) - self.height() |
||||
self._vscroller.setRange(0, scrollTo) |
||||
self._vscroller.pagestep = self.height() |
||||
|
||||
def wheelEvent(self, evt): |
||||
# delta = self.height() |
||||
delta = 5 |
||||
if evt.evt == TTkK.WHEEL_Up: |
||||
delta = -delta |
||||
# self.scrollTo(self._moveTo + delta) |
||||
self._vscroller.value = self._moveTo + delta |
||||
return True |
||||
|
||||
@pyTTkSlot(int) |
||||
def scrollTo(self, to): |
||||
max = len(self._tableData) - self.height() |
||||
if to>max: to=max |
||||
if to<0: to=0 |
||||
self._moveTo = to |
||||
self.update() |
||||
|
||||
def paintEvent(self): |
||||
y = 0 |
||||
w,h = self.size() |
||||
total = 0 |
||||
variableCols = 0 |
||||
slicesize = 0 |
||||
for width in self._columns: |
||||
if width > 0: |
||||
total += width |
||||
else: |
||||
variableCols += 1 |
||||
if variableCols > 0: |
||||
slicesize = int((w-total)/variableCols) |
||||
TTkLog.debug(f"ss:{slicesize}, w:{w}") |
||||
|
||||
maxItems = len(self._tableData) |
||||
itemFrom = self._moveTo |
||||
itemTo = itemFrom + h |
||||
if itemFrom > maxItems: itemFrom = maxItems |
||||
if itemTo > maxItems: itemTo = maxItems |
||||
for i in range(itemFrom, itemTo): |
||||
item= self._tableData[i] |
||||
line = "" |
||||
for i in range(0,len(item)): |
||||
txt = item[i] |
||||
width = self._columns[i] |
||||
if width < 0: |
||||
width = slicesize |
||||
if width > 0: |
||||
lentxt = len(txt) |
||||
if lentxt > width: |
||||
line += txt[0:width] |
||||
else: |
||||
line += txt + " "*(width-lentxt) |
||||
line += " " |
||||
lentxt = len(line) |
||||
if lentxt > w-2: |
||||
line = line[0:w-2] |
||||
else: |
||||
line = line + " "*(w-2-lentxt) |
||||
self._canvas.drawText(pos=(0,y), text=line) |
||||
y+=1 |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2021 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. |
||||
|
||||
import sys, os |
||||
import random |
||||
|
||||
sys.path.append(os.path.join(sys.path[0],'..')) |
||||
import TermTk as ttk |
||||
|
||||
|
||||
|
||||
ttk.TTkLog.use_default_file_logging() |
||||
|
||||
root = ttk.TTk() |
||||
|
||||
btn1 = ttk.TTkButton(parent=root, pos=(0,0), size=(5,3), text='On') |
||||
btn2 = ttk.TTkButton(parent=root, pos=(5,0), size=(5,3), text='Off') |
||||
btn3 = ttk.TTkButton(parent=root, pos=(0,3), size=(5,3), text='On') |
||||
btn4 = ttk.TTkButton(parent=root, pos=(5,3), size=(5,3), text='Off') |
||||
btn5 = ttk.TTkButton(parent=root, pos=(0,6), size=(5,3), text='On') |
||||
btn6 = ttk.TTkButton(parent=root, pos=(5,6), size=(5,3), text='Off') |
||||
ttk.TTkLabel(parent=root, pos=(10,1), text='zOrder and max/min size') |
||||
ttk.TTkLabel(parent=root, pos=(10,4), text='Scollbars') |
||||
ttk.TTkLabel(parent=root, pos=(10,7), text='Basic Table') |
||||
|
||||
# Testing Widgets from "test.ui.004.windows.py" |
||||
test_win1 = ttk.TTkWindow(parent=root,pos = (10,1), size=(70,35), title="Test Window 1", border=True) |
||||
test_win1.hide() |
||||
btn1.clicked.connect(test_win1.show) |
||||
btn2.clicked.connect(test_win1.hide) |
||||
|
||||
test_win2_1 = ttk.TTkWindow(parent=test_win1,pos = (3,3), size=(40,20), title="Test Window 2.1", border=True) |
||||
test_win2_1.setLayout(ttk.TTkHBoxLayout()) |
||||
ttk.TTkTestWidget(parent=test_win2_1, border=False) |
||||
|
||||
test_win2_2 = ttk.TTkWindow(parent=test_win1,pos = (5,5), size=(40,20), title="Test Window 2.2", border=True) |
||||
test_win2_2.setLayout(ttk.TTkHBoxLayout()) |
||||
ttk.TTkTestWidget(parent=test_win2_2, border=False) |
||||
|
||||
|
||||
test_win3 = ttk.TTkWindow(parent=root,pos = (20,5), size=(70,25), title="Test Window 3", border=True) |
||||
test_win3.hide() |
||||
test_win3.setLayout(ttk.TTkHBoxLayout()) |
||||
btn1.clicked.connect(test_win3.show) |
||||
btn2.clicked.connect(test_win3.hide) |
||||
|
||||
ttk.TTkTestWidget(parent=test_win3, border=True, maxWidth=30, minWidth=20) |
||||
rightFrame = ttk.TTkFrame(parent=test_win3, border=True) |
||||
rightFrame.setLayout(ttk.TTkVBoxLayout()) |
||||
|
||||
ttk.TTkTestWidget(parent=rightFrame, border=True, maxSize=(50,15), minSize=(30,8)) |
||||
bottomrightframe = ttk.TTkFrame(parent=rightFrame,border=True) |
||||
|
||||
test_win4 = ttk.TTkWindow(parent=bottomrightframe, pos = (3,3), size=(40,20), title="Test Window 4", border=True) |
||||
test_win4.setLayout(ttk.TTkHBoxLayout()) |
||||
ttk.TTkTestWidget(parent=test_win4, border=False) |
||||
|
||||
|
||||
# Scroller window from test.ui.006.scroll.py |
||||
win_scroller = ttk.TTkWindow(parent=root,pos=(30,3), size=(50,30), title="Test Window 1", border=True) |
||||
win_scroller.hide() |
||||
btn3.clicked.connect(win_scroller.show) |
||||
btn4.clicked.connect(win_scroller.hide) |
||||
win_scroller.setLayout(ttk.TTkVBoxLayout()) |
||||
top = ttk.TTkFrame(parent=win_scroller, layout=ttk.TTkHBoxLayout()) |
||||
ttk.TTkScrollBar(parent=win_scroller, orientation=ttk.TTk.HORIZONTAL, value=0, color=ttk.TTkColor.bg('#990044')+ttk.TTkColor.fg('#ffff00')) |
||||
ttk.TTkScrollBar(parent=win_scroller, orientation=ttk.TTk.HORIZONTAL, value=10, color=ttk.TTkColor.bg('#770044')+ttk.TTkColor.fg('#ccff00')) |
||||
ttk.TTkScrollBar(parent=win_scroller, orientation=ttk.TTk.HORIZONTAL, value=50, color=ttk.TTkColor.bg('#660044')+ttk.TTkColor.fg('#88ff00')) |
||||
ttk.TTkScrollBar(parent=win_scroller, orientation=ttk.TTk.HORIZONTAL, value=80, color=ttk.TTkColor.bg('#550044')+ttk.TTkColor.fg('#55ff00')) |
||||
ttk.TTkScrollBar(parent=win_scroller, orientation=ttk.TTk.HORIZONTAL, value=99, color=ttk.TTkColor.bg('#330044')+ttk.TTkColor.fg('#33ff00')) |
||||
|
||||
|
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=0) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=10) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=40) |
||||
ttk.TTkSpacer(parent=top) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=40, pagestep=3) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=50, pagestep=5) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=60, pagestep=20) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=70, pagestep=30) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=80, pagestep=60) |
||||
ttk.TTkSpacer(parent=top) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=80) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=90) |
||||
ttk.TTkScrollBar(parent=top, orientation=ttk.TTk.VERTICAL, value=99) |
||||
|
||||
|
||||
# Table window from test.ui.008.table.py |
||||
words = ["Lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit,", "sed", "do", "eiusmod", "tempor", "incididunt", "ut", "labore", "et", "dolore", "magna", "aliqua.", "Ut", "enim", "ad", "minim", "veniam,", "quis", "nostrud", "exercitation", "ullamco", "laboris", "nisi", "ut", "aliquip", "ex", "ea", "commodo", "consequat.", "Duis", "aute", "irure", "dolor", "in", "reprehenderit", "in", "voluptate", "velit", "esse", "cillum", "dolore", "eu", "fugiat", "nulla", "pariatur.", "Excepteur", "sint", "occaecat", "cupidatat", "non", "proident,", "sunt", "in", "culpa", "qui", "officia", "deserunt", "mollit", "anim", "id", "est", "laborum."] |
||||
def getWord(): |
||||
return random.choice(words) |
||||
def getSentence(): |
||||
return " ".join([getWord() for i in range(0,random.randint(6, 20))]) |
||||
|
||||
win_table = ttk.TTkWindow(parent=root,pos = (10,0), size=(60,30), title="Test Table 1", layout=ttk.TTkHBoxLayout(), border=True) |
||||
win_table.hide() |
||||
btn5.clicked.connect(win_table.show) |
||||
btn6.clicked.connect(win_table.hide) |
||||
table = ttk.TTkTable(parent=win_table) |
||||
|
||||
table.setColumnSize((20,-1,10,15)) |
||||
table.appendItem(("","You see it's all clear, You were meant to be here, From the beginning","","")) |
||||
for i in range(0, 100): |
||||
table.appendItem((str(i)+" - "+getWord(), getSentence(), getWord(), getWord())) |
||||
table.appendItem(("This is the end", "Beautiful friend, This is the end My only friend", "the end", "...")) |
||||
|
||||
|
||||
|
||||
|
||||
root.mainloop() |
||||
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2021 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. |
||||
|
||||
import sys, os |
||||
|
||||
sys.path.append(os.path.join(sys.path[0],'..')) |
||||
import TermTk as ttk |
||||
|
||||
ttk.TTkLog.use_default_file_logging() |
||||
|
||||
root = ttk.TTk() |
||||
btn1 = ttk.TTkButton(parent=root, x=0, y=0, width=15, height=3, text='Hide Window1') |
||||
btn2 = ttk.TTkButton(parent=root, x=0, y=3, width=15, height=3, text='Show Window1') |
||||
btn3 = ttk.TTkButton(parent=root, x=0, y=6, width=28, height=3, text='Hide Window2.1 and Window3') |
||||
btn4 = ttk.TTkButton(parent=root, x=0, y=9, width=28, height=3, text='Show Window2.1 and Window3') |
||||
|
||||
win1 = ttk.TTkWindow(parent=root,pos = (1,4), size=(60,30), title="Test Window 1", border=True) |
||||
# Connect the Buttons (clicked) signals to the Window slots (hide/show) |
||||
btn1.clicked.connect(win1.hide) |
||||
btn2.clicked.connect(win1.show) |
||||
|
||||
win2_1 = ttk.TTkWindow(parent=win1,pos = (3,3), size=(40,20), title="Test Window 2.1", layout=ttk.TTkHBoxLayout(), border=True) |
||||
btn3.clicked.connect(win2_1.hide) |
||||
btn4.clicked.connect(win2_1.show) |
||||
ttk.TTkTestWidget(parent=win2_1, border=False) |
||||
|
||||
|
||||
win2_2 = ttk.TTkWindow(parent=win1,pos = (5,5), size=(40,20), title="Test Window 2.2", layout=ttk.TTkHBoxLayout(), border=True) |
||||
ttk.TTkTestWidget(parent=win2_2, border=False) |
||||
|
||||
|
||||
win3 = ttk.TTkWindow(parent=root,pos = (20,7), size=(60,20), title="Test Window 3", layout=ttk.TTkHBoxLayout(), border=True) |
||||
btn3.clicked.connect(win3.hide) |
||||
btn4.clicked.connect(win3.show) |
||||
|
||||
ttk.TTkTestWidget(parent=win3, border=True, maxWidth=30, minWidth=20) |
||||
rightFrame = ttk.TTkFrame(parent=win3, layout=ttk.TTkVBoxLayout(), border=True) |
||||
|
||||
ttk.TTkTestWidget(parent=rightFrame, border=True, maxSize=(50,15), minSize=(30,8)) |
||||
bottomrightframe = ttk.TTkFrame(parent=rightFrame,border=True) |
||||
|
||||
win4 = ttk.TTkWindow(parent=bottomrightframe, pos = (3,3), size=(40,20), title="Test Window 4", layout=ttk.TTkHBoxLayout(), border=True) |
||||
ttk.TTkTestWidget(parent=win4, border=False) |
||||
|
||||
root.mainloop() |
||||
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
# MIT License |
||||
# |
||||
# Copyright (c) 2021 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. |
||||
|
||||
import sys, os |
||||
import random |
||||
|
||||
sys.path.append(os.path.join(sys.path[0],'..')) |
||||
import TermTk as ttk |
||||
|
||||
words = ["Lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit,", "sed", "do", "eiusmod", "tempor", "incididunt", "ut", "labore", "et", "dolore", "magna", "aliqua.", "Ut", "enim", "ad", "minim", "veniam,", "quis", "nostrud", "exercitation", "ullamco", "laboris", "nisi", "ut", "aliquip", "ex", "ea", "commodo", "consequat.", "Duis", "aute", "irure", "dolor", "in", "reprehenderit", "in", "voluptate", "velit", "esse", "cillum", "dolore", "eu", "fugiat", "nulla", "pariatur.", "Excepteur", "sint", "occaecat", "cupidatat", "non", "proident,", "sunt", "in", "culpa", "qui", "officia", "deserunt", "mollit", "anim", "id", "est", "laborum."] |
||||
def getWord(): |
||||
return random.choice(words) |
||||
def getSentence(): |
||||
return " ".join([getWord() for i in range(0,random.randint(8, 30))]) |
||||
|
||||
|
||||
ttk.TTkLog.use_default_file_logging() |
||||
|
||||
root = ttk.TTk() |
||||
win1 = ttk.TTkWindow(parent=root,pos = (3,3), size=(40,20), title="Test Table 1", layout=ttk.TTkHBoxLayout(), border=True) |
||||
table = ttk.TTkTable(parent=win1) |
||||
|
||||
table.setColumnSize((20,-1,10,15)) |
||||
table.appendItem(("","You see it's all clear, You were meant to be here, From the beginning","","")) |
||||
for i in range(0, 100): |
||||
table.appendItem((str(i)+" - "+getWord(), getSentence(), getWord(), getWord())) |
||||
table.appendItem(("This is the end", "Beautiful friend, This is the end My only friend", "the end", "...")) |
||||
|
||||
|
||||
|
||||
|
||||
root.mainloop() |
||||
Loading…
Reference in new issue