I\'m using Python 2 with Tkinter and PyObjC, and then I\'m using py2app.
The program is working fine, but the window starts a
The osascript trick Arnaud P could have problems, if there is more than one process with the application title ‘Python’; additionally, it will not work for Python 3 processes (needs to be called ‘Python3’ then.
However, I found another trick that can solve the problem by using the process id.
import os
script = 'tell application "System Events" \
to set frontmost of the first process whose unix id is {pid} to true'.format(pid=os.getpid())
os.system("/usr/bin/osascript -e '{script}'".format(script=script))