How To: MacPython and Tkinter (english)
Programming graphical user interfaces (GUI's) with the Tk-toolkit and MacPython is easy and fun. But unfortunately if you try the simplest demo script with a freshly installed MacPython you will get the following error messages:
Traceback (innermost last): File "MacHD:Python 1.5.2c1:Demo:tkinter:matt:animation-w-velocity-ctrl.py", line 1, in ? from Tkinter import * File "MacHD:Python 1.5.2c1:Lib:lib-tk:Tkinter.py", line 8, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter
This is caused by a bug in the MacPython1.5.2c1 installer: it puts the shared libs »_tkinter.CFM68K.slb« and »_tkinter.ppc.slb« into the folder »PIL« which is in the folder »Imaging« in the folder »Extensions«. You have to put one (or both "Sidesmiley") of these files in the folder »PlugIns« which is in the folder »Mac«. In addition, the standard installation has no path to »$(PYTHON):Lib:lib-tk«. You must add this path manually using the program »EditPythonPrefs«.
You must run Tkinter based scripts using the interpreter (PythonInterpreter) rather than the IDE (Python IDE). This is documented. "Sidesmiley" Unfortunately there are two bugs in the interpreter to watch out for:
Thanks to Russell E. Owen for his help by the english version.
© Copyright 2000 - 2002: Jörg Kantel.
Last update: 13.10.2002; 21:33:49 Uhr.