[Pythonmac-SIG] Starting Up Front.

Bob Ippolito bob at redivi.com
Mon Oct 25 23:30:59 CEST 2004


On Oct 25, 2004, at 17:09, Jerry LeVan wrote:

> I am using Aqua Tcl/Tk BI distribution ( most recent). The
> Aqua version does not naturally start with the application
> being brought to the front. In Tk I can do any of:
>
> # any of the following three "includes" will work with aqua
> # to insure that the wish window is frontmost.
>
> #package require tclAE
> #tclAE::send -s misc actv
>
> catch {
> package require Tclapplescript
> AppleScript execute {tell me to activate}
> }
>
> #exec osascript \
> #      -e "tell app \"Finder\" to set frontmost of process \"Wish 
> Shell\" to true"
>
> How can I do any/all of the above in Python?

The first one would be this (call activate):

from Carbon import AE, AppleEvents

def currentProcessDesc():
     kCurrentProcess = '\x00\x00\x00\x00\x00\x00\x00\x02'
     return AE.AECreateDesc(
         AppleEvents.typeProcessSerialNumber,
         kCurrentProcess)

def activateDesc():
     return AE.AECreateAppleEvent(
         AppleEvents.kAEMiscStandards,
         AppleEvents.kAEActivate,
         currentProcessDesc(),
         AppleEvents.kAutoGenerateReturnID,
         AppleEvents.kAnyTransactionID)

def activate():
     return activateDesc().AESend(
         AppleEvents.kAEWaitReply,
         AppleEvents.kAENormalPriority,
         AppleEvents.kAEDefaultTimeout)


Are you sure that bundled applications don't start in front?

-bob



More information about the Pythonmac-SIG mailing list