tktable icon indicating copy to clipboard operation
tktable copied to clipboard

_tkinter.TclError: invalid command name "table"

Open ghiewa opened this issue 7 years ago • 12 comments

python 2.7.13

Traceback (most recent call last):
  File "E:\IDP\SetupIDE.py", line 47, in <module>
    table = tktable.Table(fields_tab, rows=10, cols=4)
  File "E:\IDP\tktable.py", line 128, in __init__
    tkinter.Widget.__init__(self, master, 'table', kw)
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 2096, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"`

ghiewa avatar Jul 10 '17 06:07 ghiewa

@ghiewa It looks like tktable is not installed.

nbro avatar Jul 15 '17 01:07 nbro

Try installing the tk-table package.

sudo apt-get install tk-table (for linux use the respective windows command)

Worked for me

yashkark avatar Nov 12 '17 01:11 yashkark

@yashkark I tried to install the package and it did not work. Please advise how to install the package and I am using anaconda. I t made me crazy. Thank you very much.

Goujun avatar Dec 08 '17 01:12 Goujun

@Goujun Which operating system are you using exactly?

sudo apt-get install tk-table only works on a few Linux distros.

By the way, I am not sure if using Anaconda is going to cause you problems, given that I am not sure if Anaconda distribution of Python actually supports or not tkinter. Have you checked if there are table libraries specifically for Anaconda?

nbro avatar Dec 08 '17 02:12 nbro

@nbro , thank you for your reply and I am using Windows 10 and anaconda environment.

Goujun avatar Dec 08 '17 17:12 Goujun

@Goujun If that is not working you can just download the tktable.py file put it in the same folder as your project and import tktable.

yashkark avatar Dec 08 '17 18:12 yashkark

@yashkark I tried that method, however, it gave me the same error, that is very weird. That was why I tried to install the package. Sorry to trouble you.

Goujun avatar Dec 08 '17 18:12 Goujun

@Goujun What @yashkark is suggesting doesn't work if the underlying Tcl/Tk implementation does not have the tktable (written in Tcl/C) installed.

This Python library is a "wrapper" library around the Tcl/Tk tktable library, that is, this library is a bunch of functions and classes to access another library (written in another language different from Python), which you first need to install!

nbro avatar Dec 08 '17 18:12 nbro

@Goujun

import Tkinter as tk
import tktable

def table_test():

    #### DEFINES THE GUI ####
    master = tk.Tk()
    master.geometry('800x800+250+200')
    master.title('Dogs')

    #### SETS THE DOG INTO THE TABLE ####
    def callback_dogs(event):
        values = ['Doodle','Pug','Westie','Poodle']
        for item in values:
            return item

    #### DEFINING THE TKTABLE ####
    tb = tktable.Table(master, state='disabled', width=15, titlerows=1, rows=3, cols=2, command=callback_dogs)
    tb.pack(expand=1)

    #### MAINLOOPING ####
    master.attributes('-topmost',True)
    master.after_idle(master.attributes,'-topmost',False)
    tk.mainloop()

table_test()

This worked for me. If it is not for you try using something else. What exactly are you looking to do? You can try out the Tkinter treeview.

yashkark avatar Dec 08 '17 18:12 yashkark

@yashkark Yes, but this means that you already had the underlying Tk library tktable installed, otherwise that code would give you an error.

nbro avatar Dec 08 '17 20:12 nbro

@nbro Thank you for your advice and does that mean I need to install new Tcl/Tk which support tktable library first? @yashkark, thank you very much, I want to implement the automation test which allows me to do tasks in parallel. I want to grab data from instruments and show them on the screen, after the test completes, I will save the data.

Goujun avatar Dec 08 '17 21:12 Goujun

@Goujun Yes, exactly. Sorry for this late reply: I hope you were able to solve your problem meanwhile.

nbro avatar Jan 01 '18 15:01 nbro