[Pythonmac-SIG] python + code double-clickable .app bundle?

Ivan Kozik ivan@allometra.com
Sun, 22 Dec 2002 13:56:03 -0800


I just looked at the source code some more and figured I can put a 
__main__.py file in Resources/ which will be run by the python 
interpreter.

On Sunday, December 22, 2002, at 01:10  PM, Ivan Kozik wrote:

> Hello,
>
> I am trying to combine the python interpreter and a python source code 
> file into a .app bundle on Mac OS X 10.2. The only way I know of 
> starting it now is:
> open -a python code.py
> (which is obviously not a good solution).
>
> Since the python interpreter requires an argument to execute 
> something, I tried to replace the main binary with a compiled C 
> executable (in the .app bundle) that executes the python interpreter 
> with the source code as an argument. (The finder and 'open' executes 
> the binary in MacOS/ with the full path, so I can easy chdir() to this 
> directory and run an executable):
>
> #include <stdio.h>
> main(int argc, char **argv) {
>         char *loc;
>         char *p;
>         loc = argv[0];
>         if (p = strstr(loc, "MacOS/ProgramName")) strcpy(p, "MacOS/");
>         chdir(loc);
>         system("exec ./python ./sourcecode.py");
> }
>
> I have tried this program with the "exec" in the system() and without 
> the "exec" too. The problem is that my program uses Tkinter, and 
> whenever i click on or try to move the window with my "solution", I 
> get:
> SetFrontProccess failed,-606
> (in the console).
> I'm guessing this problem appears because the new python process has a 
> different PID from what the Dock and Finder expects.
> This problem did not appear when used 'open -a python sourcecode.py'.
>
> I have also tried modifying the python source code 
> (Python-2.2.1/Mac/Python/macmain.c) to run my source code file at 
> startup (without an argument) but I failed (I barely know C and how 
> the python internals work).
>
> My question is, is there any way to run the python program in a .app 
> bundle without an argument to the source code? (and have the mac os x 
> windowing manager properly recognize my window)?
>
> Thanks,
> Ivan
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>