Skip to content

Adding row to table causes exception #326

Description

@uninstall-your-browser

Demo code:

import TermTk as ttk

if __name__ == '__main__':
    root = ttk.TTk()

    window = ttk.TTkWindow(parent=root, layout=ttk.TTkVBoxLayout(), size=(30, 15), pos=(0,0))
    model = ttk.TTkTableModelList(data=[["hello"]], header=["h1"])
    table = ttk.TTkTable(parent=window, tableModel=model)
    button = ttk.TTkButton(parent=window, text="Add item")

    @ttk.pyTTkSlot()
    def on_click():
        model.setModelList(model.modelList() + ["more hello"])

    button.clicked.connect(on_click)

    window.show()
    root.mainloop()

Error:
Click the add button.
You may need to click or scroll on the table a bit for the error to happen (changing the list doesn't update the table, which might be another bug).

Traceback (most recent call last):
  File ".../lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File ".../TermTk/TTkCore/timer_unix.py", line 55, in run
    self.timeout.emit()
  File ".../TermTk/TTkCore/signal.py", line 139, in emit
    slot(*args[sl], **kwargs)
  File ".../TermTk/TTkCore/ttk.py", line 314, in _time_event
    TTkHelper.paintAll()
  File ".../TermTk/TTkCore/helper.py", line 323, in paintAll
    widget.paintEvent(canvas)
  File ".../TermTk/TTkWidgets/TTkModelView/tablewidget.py", line 1521, in paintEvent
    ya,yb = sliceRow[row]
            ~~~~~~~~^^^^^
IndexError: list index out of range

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions