Home

Tktable for Tkinter and Python


Honestly, I’m still having trouble figuring out how to make the Tktable component for Tkinter work like a spreadsheet in the Tkinter application I’m developing, but I found some interesting information that might make what I had to go through to get to this point easier for someone else in my shoes. I might just end up dynamically creating Entry components, but I’d rather get this working.

Getting Tktable setup under Python 2.3 for Windows

You need four files to get Tktable working:

  • tktable.dll
  • pkgIndex.tcl
  • tkTable.tcl
  • tktable.py

They go into Python folder like so:

C:\Python2.x 
| +--- tcl | 
| | +--- Tktable2.7 
| | | +--- pkgIndex.tcl 
| +--- Tktable.dll 
| +--- tkTable.tcl 
| 
| +--- Lib 
| +--- lib-tk 
| +--- tktable.py

You can get the first three files from the Win32 binary distribution of Tktable 2.7 the tktable.py is a python wrapper for the component and can only be found the demos folder of the newest edition of the source code found here: Tktable 2.9 Source

Once you’ve gotten all the files in the right place you should be able to setup a Python script to use the table. You could also just run the tktable.py file through the interpreter to make it it works. Click the “read more” link to see my modified version of that code (the old test code it ships with seems to be a little broken in spots)

Resources

  • Tktable Website
  • Tktable BDG – specific information about using Tktable in actual TCL. However a lot of the implementation can be adapted to using the component in Tkinter/Python.
  • Table/Matrix Widget Docs v2.5 – purely documentation on the TkTable class. This documentation is a bit older, but there is information to be gleaned from its horrible layout :)
  • Tktable Wiki page at tcl.tk – A discussion on using Tktable in a TCL context but is useful for pure Tktable information