Pysimplegui: Table needs headings argument

Created on 28 May 2019  路  8Comments  路  Source: PySimpleGUI/PySimpleGUI

Type of Issues (Enhancement, Error, Bug, Question)

Call for documentation improvement/bug: Table causes _tkinter.TclError: Column index ... out of bounds when called withoutheadings`` argument. This was not clear to me from the documentation and cost me quite some time to figure out.

Operating System

Ubuntu 16.04

Python version

3.5.2

PySimpleGUI Port and Version

3.35.0

Code or partial code causing the problem

Remove the headings line below to trigger the error.

import PySimpleGUI as sg
from random import randint as rand

def table_example():
    data = [list(str(rand(0,50)) for i in range(5)) for i in range(10)]
    header_list = ['C1', 'C2', 'C3', 'C4', 'C5']
    layout = [[
        sg.Table(
            values=data,
            num_rows=min(len(data), 20),
            headings=header_list
        )
    ]]
    window = sg.Window('table', layout)
    event, values = window.Read()

table_example()
Bug Done - Download from GitHub documentation

Most helpful comment

I'm using a special, purpose built, documentation generator that takes my docstrings and converts them into a nicely formatted markdown. So, it's about as easy as I could hope for at the moment. It used to be real hell to keep track of the APIs and make sure the docs reflected what was currently in the code. Now it gets it from the code so that problem's been resolved.

This section of the User Manual shows the detailed documentation for every element and function call:
https://pysimplegui.readthedocs.io/en/latest/#element-and-function-call-reference

It's the documentation that's been soaking up 80% of my time for the past month. It's getting there..... Next up is transferring as many of the docstrings as possible over to the other ports. A lot has happened since the May 28th day of the last post in this Issue. 馃槂

That said, lemme make sure that this error is correctly documented.

All 8 comments

You at least shouldn't get that error.

I'll also look at the docs. They need updating pretty badly!

Perhaps it would be worth to switch to sphinx/readthedocs for automatically generated documentation. This
might save a lot of trouble in the long run. But I understand that it also would require a lot of work at the beginning to get it started.

I'm using a special, purpose built, documentation generator that takes my docstrings and converts them into a nicely formatted markdown. So, it's about as easy as I could hope for at the moment. It used to be real hell to keep track of the APIs and make sure the docs reflected what was currently in the code. Now it gets it from the code so that problem's been resolved.

This section of the User Manual shows the detailed documentation for every element and function call:
https://pysimplegui.readthedocs.io/en/latest/#element-and-function-call-reference

It's the documentation that's been soaking up 80% of my time for the past month. It's getting there..... Next up is transferring as many of the docstrings as possible over to the other ports. A lot has happened since the May 28th day of the last post in this Issue. 馃槂

That said, lemme make sure that this error is correctly documented.

OK, just ran the sample code again and it's doing what I thought it was doing all along. If you don't specify headings, then the first row of data is used as the headings.

Thanks for your great efforts!

I just upgraded to the recent v4.3.2 but still get the same error if I leave out the headings parameters.

Here's the snippet (same as above only without headings):

import PySimpleGUI as sg
from random import randint as rand

def table_example():
    data = [list(str(rand(0,50)) for i in range(5)) for i in range(10)]
    header_list = ['C1', 'C2', 'C3', 'C4', 'C5']
    layout = [[
        sg.Table(
            values=data,
            num_rows=min(len(data), 20),
        )
    ]]
    window = sg.Window('table', layout)
    event, values = window.Read()

table_example()

and this is the error:

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    table_example()
  File "test.py", line 14, in table_example
    event, values = window.Read()
  File "/home/user/.local/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 5321, in Read
    self._Show()
  File "/home/user/.local/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 5197, in _Show
    StartupTK(self)
  File "/home/user/.local/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 8734, in StartupTK
    ConvertFlexToTK(my_flex_form)
  File "/home/user/.local/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 8639, in ConvertFlexToTK
    PackFormIntoFrame(MyFlexForm, master, MyFlexForm)
  File "/home/user/.local/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 8365, in PackFormIntoFrame
    selectmode=element.SelectMode, )
  File "/usr/lib/python3.5/tkinter/ttk.py", line 1175, in __init__
    Widget.__init__(self, master, "ttk::treeview", kw)
  File "/usr/lib/python3.5/tkinter/ttk.py", line 553, in __init__
    tkinter.Widget.__init__(self, master, widgetname, kw=kw)
  File "/usr/lib/python3.5/tkinter/__init__.py", line 2142, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: Column index 8 out of bounds

(if the header is specified, everything works as expected)

try the github version not the released version

Right :) Works for me as well! Thanks a lot for your work!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucasea777 picture lucasea777  路  3Comments

yogesh-aggarwal picture yogesh-aggarwal  路  3Comments

mozesa picture mozesa  路  5Comments

xuguojun168 picture xuguojun168  路  3Comments

thelou1s picture thelou1s  路  4Comments