On 1/4/10 8:18 AM, Kevin Walzer wrote:
On 1/4/10 6:37 AM, has wrote:

Sounds like you forgot to add an OSAScriptingDefinition entry
containing the sdef's filename to your info.plist.

Also, bear in mind that sdef-only apps won't work in 10.4 or earlier;
if that's a concern then you'll need to provide an aete as well.


That worked, thanks. But now Script Editor complains about a "corrupted
dictionary." Looks fine to me. Any ideas?


Thanks to has for the off-list reply: I found a couple of errors in the sdef file.

Now my app responds to Apple Events and doesn't complain about a corrupted dictionary. However, I'm having some additional difficulty. It appears that Apple Events are bypassing the bundled Python and are going straight to the Tk framework instead. Tk/Aqua has pretty good AppleScript support, and implements a "do script" command that will execute Tcl scripts. My application responds to this code:

tell app MyApp
        do script "puts \"foo\""
end tell

but returns an error message for

tell app MyApp
        do script "print \"foo\""
end tell

because it's expecting Tcl code.

This is very weird, and I have no clue how to untangle it. My app won't respond to Apple Events at all without a valid sdef file in the bundle's Resources directory. However, if the sdef is present, the commands and Apple Events defined there are ignored and are instead handled by the Tcl/Tk interpreter and its sdef instead. To avoid this conflict, I've tried removing the Tk sdef file, and changing the Apple Event class/ID of my Python event to something else, but these have no effect.

It's possible to wrap Tk calls in Python code via ('root', 'tk', 'call'), and it's also possible to force Python code to stand in as Tcl code via the "register" function, but I don't know if either of these would be applicable solutions in this instance; if the Apple Events are going directly to the Tcl interpreter embedded in the Tk framework, then it may not really be possible to send Apple Events to a bundled Python application using Tkinter.

Has anyone else encountered anything like this, with Tkinter or another toolkit?

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to