[Pythonmac-SIG] Embedding Python invisibly

Jack Jansen jack@oratrix.nl
Fri, 05 Oct 2001 13:38:36 +0200


Recently, Paul Miller <paul@fxtech.com> said:
> Jon,
> 
> Yep - you can do everything you want to do. But it'll take some work...
> 
> >1. Python is embedded in the application (invisibly?)
> 
> Just link with the Python library and initialize it normally.

Well, almost normally. You should call PyMac_Initialize(), not
Py_Initialize(). There may be some issues currently if your toolboxes
are already initialized, Alexandre Parenteau is looking at
this. Or was I going to do it? I don't remember anymore... Alexandre,
could you enlighten me again?

> The main 
> issue here with making it "invisible" is on Mac it wants to open a Console 
> no matter what you do. If anyone has figured out how to avoid this, I'd 
> love to hear about it!

The easiest way to do this is to drop your application on
EditPythonPrefs and set the "no console until needed" option. What
EditPythonPrefs does for applets also works for applications embedding
Python.

This is explained in :Mac:Demo:embedding.html, but it may need to be a
bit more verbose. Suggestions as to a better text for the single line
in there are hereby requested. Actually, the whole embedding.html
could use more detail, but I've never really embedded MacPython
myself, so maybe someone else wants to pick this up?
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.cwi.nl/~jack        | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm