Mac Python Questions

Louis M. Pecora pecora at anvil.nrl.navy.mil
Sun Apr 30 10:14:01 EDT 2000


In article <IRjL4.271$CP3.3183 at news.uswest.net>, Jeff Massung
<jmassung at magpiesystems.com> wrote:

> Okay, I've been looking all over the net and the documentation that came
> with the MacPython distribution, but can't seem to find the answers to these
> questions. Hopefully someone else out there on a Mac can help me out?
> 
> a) There is a file In $(PYTHON):Mac:Contrib:... called PyColorEdit.py. Good
> color editor. I would like to use that instead of PyEdit.py. Is there a way
> to install the color one?

Don't know about that one.
 
> b) No matter what I do, I can't get Tkinter to work :(. Lately I'm led to
> believe that the Mac version of Python doesn't use it, but uses the Mac
> stuff instead. Is this the case? If not, how can I get Tkinter to work?
> Whenever I run something that imports it, it dies on the line with the
> comment "If this dies your computer might not be set up for tkinter". How
> can I set up my machine for it? Thanks :)

Here are two "answers" re: MacPython & Tk I culled from previous
messages.  Maybe they'll help.  Also, you should tune into the
PythonMacSIG (see: http://www.python.org/pipermail/pythonmac-sig/ and
http://www.python.org/mailman/listinfo/pythonmac-sig.  Good people hang
out there who can give lots of answers.

---------------------------------------------------

(1) Tk and setting the right Mac path

Thanks to Ben Coburn and Richard Gordon I was able to get Tk to work on
my mac.  I fixed the problem by placing the following path's in the
Python Preferences:

$(PYTHON):Lib:lib-tk $(PYTHON):Extensions:Imaging:PIL

Is there a reason that these two paths are not automatically set during
the installation.  I was a bit frustrated when I couldn't get through
the example code in Chapter 1 of Learning Python (pg 23 has a Tk
sample).

(2) How to: Tk on Mac

Programming graphical user interfaces (GUI's) with the Tk-toolkit and
MacPython is easy and                        makes fun. But
unfortunately if you try the simplest demo script with a fresh
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

The reason therefore is a bug in the installer of MacPython1.5.2c1: It
puts the shared libs »_tkinter.CFM68K.slb« as well as
»_tkinter.ppc.slb« in the folder »TK« which is in the folder »Imaging«
in the folder »Extensions«. You have to put one of them (or both ) in
the folder »PlugIns« which is in the folder »Mac«.

And also the fresh standard installation has no path to
»$(PYTHON):Lib:lib-tk«, you have to add that manually with the program
»EditPythonPrefs«.

Unfortunately there is also a bug within the interpreter. Calling
»Tkinter« from the interpreter interactivetely freezes them. You can
only run Tk-based Python scripts by typing them in your editor and
running them by dropping over the interpreter or saving them as Python
files and starting them by doubleclick.

And you never can run Tkinter based scripts from the IDE. But this
behaviour is documented.



More information about the Python-list mailing list