[Pythonmac-SIG] Difference between pythonw and python?

Michael Hudson mwh at python.net
Thu Apr 1 05:34:06 EST 2004


Jens Miltner <jum at mac.com> writes:

> Am 31.03.2004 um 17:39 schrieb Jack Jansen:
>
>> Then it could be you're running up against a completely different
>> problem. Does the hosting application have its own GUI mainloop?
>> Because if it has (and note it could be implicit, if you use Cocoa
>> or CarbonEvents)  then you will probably run into problems with your
>> mainloop and Tk's mainloop getting in each others hair.
>
> Yes, but I don't even get that far - python raises an exception that
> Tk is not a known symbol, even though the script imported * from
> Tkinter...

This is very odd, and sounds like your problem may be something
entirely other than what you think it is...

> Strangely, the python scripts run fine when launched from the
> commandline, but when executed using PyRun_SimpleString from within
> our app, I get an error "NameError: name 'Tk' is not defined" when
> trying to instantiate Tk(), even though the "from Tkinter import *"
> statement did pass successfully...

Maybe you could chuck a 'print dir()' in somewhere?  Or an 'import
Tkinter' and a 'print dir(Tkinter)'.

Actually, what I suspect is happening is that somewhere you're trying
to import Tkinter, it fails from being unable to import _tkinter but
somehow gets silenced, so when you import Tkinter again you get a
half-baked module.  Perhaps you could try importing _tkinter directly
where your suspect Tkinter import is?  That way you might get a better
error message, at least.

debugging-by-remote-flailing-ly y'rs,
mwh

-- 
  ZAPHOD:  You know what I'm thinking?
    FORD:  No.
  ZAPHOD:  Neither do I.  Frightening isn't it?
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 11



More information about the Pythonmac-SIG mailing list