On 1/6/10 4:58 AM, has wrote:
Though personally I'd be looking to add a proper AE API, even if only
procedural, so that users can't just run arbitrary code. But that's your
decision, not mine.
Following has's advice here, I'm trying to implement a basic API (set of
Python commands/functions) in one of my apps. However, it's not working,
perhaps because of scoping issues.
My Python apps basically run in a single fooApp class, and everything
runs inside the class. To launch the app (my apps are Tkinter-based), I
use something like this:
if __name__== '__main__':
app = fooApp(None)
app.mainloop()
I've added a doCommand function inside the app class to provide some
basic functionality in response to an AppleScript: it will set some
objects/variables, then display the output in the app. In my code it
looks like this:
def runCommand(self, string):
self.searchterm=string
self.servertree.selection_set('Default')
self.getInfo()
However, I'm having some trouble with getting this out to AppleScript.
My script:
tell application "FooApp"
run script "fooApp.runCommand(\"inputstring\")"
end tell
returns this error:
NameError: name 'fooApp' is not defined
What's the best way to structure the command so that it can be seen from
AppleScript, i.e. run in the proper scope and not return an error?
--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