Ok, that explains a lot, but I don't know of any easy way to do have javascript talk to python.
I can think of some horrible ways to do it, though. 1. Make a python web service running locally, and build up SOAP calls or HTTP posts to it. (same as I suggested earlier) 2. Use XUL and pyXPCOM to make a firefox extension that talks to python. This is probably much more of a pain in the ass than you want to do, but that's the only way I know of to directly call python functions from javascript. 3. Look into web framework Zope, that might have some of this plumbing done already. 4. Check out Sajax, http://www.modernmethod.com/sajax/, a framework to automate javascript calling your server-side functions. It was made for PHP, but looks to have a python version as well. All of those but #2 require you to set up some kind of server. Is there a reason it has to be an HTML page? If not, making a GUI might be an alternative that sidesteps this altogether. Thanks, Ryan -----Original Message----- From: Mike Hall [mailto:[EMAIL PROTECTED] Sent: Friday, March 25, 2005 3:46 PM To: Ryan Davis Cc: tutor@python.org Subject: Re: [Tutor] Python and Javascript Ryan, I should clarify that what I'd like to do here is unrelated to the web. I'm actually just interested in using a local html page as a simple gui to launch python calls. So a JS event handler, say a button click, would then call a JS function which inside of it would call a Python function while handing it arguments (say a path that the JS queried from a field in the html page.) That kind of thing. It seems like it should be possible, and hopefully easy, but I have no experience in calling Python functions from other languages so I'm just looking for some input on that. Thanks, -MH On Mar 25, 2005, at 12:01 PM, Ryan Davis wrote: > Depends on your environment. > > If your js is on a webpage, you can have it make http calls to a > python web service. Look for articles on XMLHttpRequest in > javascript to see some examples. > > I don't know how else that could be done, but I imagine there are > other ways. > > Thanks, > Ryan > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Mike Hall > Sent: Friday, March 25, 2005 2:18 PM > To: tutor@python.org > Subject: [Tutor] Python and Javascript > > I'm curious on whether or not JavaScript and Python can talk to each > other. Specifically, can a python function be called from within a JS > function? Admittedly this is probably more of a JavaScript than Python > question, but I'd love to know if anyone can at least point me in a > direction to research this. > > > -MH > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor