Python and Tk

Forum: Programming and Scripting
Topic: Python and Tk
started by: cgeorge

Posted by cgeorge on Dec. 10 2006,03:35
Has anybody gotten Python working with Tkinter TCL/Tk. I've tried both the 2.3 and 2.5 version and both say they can't find the Tkinter libraries (or weren't compiled for them).

I even tried to recompile myself from sources and ran into the same problem. I couldn't seem to get the Tk libraries to be seen by the Python make file. There are a ton of Python programs that need this to work.


Posted by mikshaw on Dec. 10 2006,15:44
I haven't done anything with python beyond using it with Blender, so I can't say for sure what might be needed for python-tk or tkinter. When building the tcl/tk extensions, I didn't even take python into consideration.  I'll have to look into that at some point, particularly since I still want to do more tweaking of the tcl/tk extension.

I wonder if it might just need some modification of your environment, such as setting a library path before running python.

Posted by cgeorge on Dec. 11 2006,17:48
I noticed the problem first when I tried to run IDLE the IDE that comes with python. It errors out and says it hasn't been "configured" for Tk. I found that when I tried rebuild python 2.5 from sources I get a warning saying that it couldn't find the Tk libraries. So I'd imagine that they need to be present when python builds or it doesn't even make the tkinter extensions that its GUI library needs later.
Posted by mikshaw on Dec. 11 2006,22:04
The existing Tcl/Tk extensions do not include the headers needed to compile Tcl/Tk applications, so maybe that's why the libraries couldn't be found.
I built a 8.4.14 Tcl/Tk package quite a while ago that includes the necessary headers, but apparently I forgot to mail it to roberts...i don't see it in my "sent" box.
Anyway, in case I don't get around to sending it soon (2K/s uploading is kind of annoying), you should be made aware that Tcl/Tk compiles very easily in DSL.

Posted by ubermai on Jan. 10 2007,02:39
I built Tcl and Tk from source files, and created .unc extensions for both. They seem to function, but Python still does not seem to recognize the needed files for Tkinter, and thus IDLE.

Perhaps the source package I used did not include the Tkinter libraries or something. Or perhaps my extensions are faulty.

Do I need to use some other package for Python? I am currently using the python2.5.unc file posted in the repository.

- UberMai

Posted by cgeorge on Jan. 10 2007,13:25
If you have Tcl/Tk installed then the Python libraries need to be rebuilt. The Python make file gives a warning that it isn't building the Tcl/Tk extensions because it can find the libraries, so I'd imagine that if you have the libraries available then it will build the extensions and then everything should work.
Posted by ubermai on Jan. 10 2007,20:23
Okay, I'll try making my own python extension with Tcl/Tk's libs and stuff.

If it works, I'll let you guys know.

Posted by ubermai on Jan. 27 2007,20:59
I built Python 2.5 from source a bunch of times now, with Tcl/Tk previously installed.

Tkinter still doesn't work.


Posted by mikshaw on Jan. 28 2007,03:08
After finally looking through my project files (yes, I'm slow and lazy....get used to it) I see that I never actually completed the tcl/tk upgrade to 8.4.14 including the headers. This would probably help in building Python to use tkinter (although it's just a guess...i've never used or installed tkinter).  Gimme a day or two to sober up and finish putting this package together, and another few days for roberts to get it and add to testing, and then maybe (MAYBE!) it will provide what you need to build python against tcl/tk.

Either that, or you could build tcl/tk on your own machine. It's actually quite easy to do in DSL

Posted by ubermai on Jan. 28 2007,04:31
I already built Tcl/Tk from source packages, and built a .unc extension for them (combined). I tried compiling Python while the .unc extension was mounted, but the extension might be missing the headers... I'm not sure if they are installed with make install.

When I compiled/installed Tcl/Tk to the ramdisk, Python built quite well. I just wasn't able to preserve that installation, or put it into an extension properly.

It's quite possible I'm omitting files from the extensions I build. I don't know how to make sure I have all of them.

Posted by ubermai on Jan. 29 2007,00:34
I have successfully created the packages in question.

My tcltk8.4.14-incl.headers.unc works well enough to compile python with tkinter.

My python2.5-incl.idle.unc is just as the filename implies. IDLE (and its prerequisites) works!


.UNCs, anyone?


Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.