[Pythonmac-SIG] just one apple event
Mon, 13 Dec 1999 11:00:03 +0000
At 12:19 pm -0800 12/12/99, Dante wrote:
>I don't think I stated my problem clearly. Once I build modules with
>gensuitemodule.py I am able to make the call as I (more or less)
>normally would. But I am left with several k of python code that I
>don't necessarily need or want. Somewhere in the files created by
>gensuitemodule.py Python sends the appleevent "misc, dosc,
>"----":"workspace.foo", &tran:63464" to "LAND". That event is
>identical to the one sent by the applescript one liner I can write
>to do this job except for the &tran which is replaced with
>For instance, in UserTalk (which bears a striking resemblance to
>Python) there is the following call: appleevent("LAND", "misc",
>"dosc", "----", "workspace.foo") which is pretty self explanatory.
>What I want is the python version of this one liner and I can't seem
>to figure out where I go for this.
You build a wrapper module that does just this for you. See
Python->Mac->Lib->findertools.py for an example of this for the
finder. This gives a syntax which is similar to Applescript, i.e.
in applescript you have
Tell application "finder" to sleep
in Python its
A word of caution. Python only allocates/can use one transaction
number per session. So if your script calls do_script more than once
it will fail. So far I have only found this to be a problem scripting
Hypercard, where there are lots of alternatives, but YMMV
Bill Bedford mailto://firstname.lastname@example.org
"So we're surrounded by absolutely nothing. There's a word for it.
It's what you get when there's nothing left and everything's been used
up." - "Yes. I think it's called the bill."