1 """nsremote - Control Netscape from python.
3 Interface modelled after unix-interface done
4 by hassan@cs.stanford.edu.
6 Jack Jansen, CWI, January 1996.
9 # Note: this module currently uses the funny SpyGlass AppleEvents, since
10 # these seem to be the only way to get the info from Netscape. It would
11 # be nicer to use the more "object oriented" standard OSA stuff, when it
12 # is implemented in Netscape.
20 Error
= 'nsremote.Error'
27 _talker
= Netscape
.Netscape()
31 list = _talker
.list_windows()
32 return map(lambda x
: (x
, 'version unknown'), list)
34 def geturl(windowid
=0, dpyinfo
=""):
37 ids
= _talker
.list_windows()
39 raise Error
, 'No netscape windows open'
41 info
= _talker
.get_window_info(windowid
)
44 def openurl(url
, windowid
=0, dpyinfo
=""):
49 _talker
.OpenURL(url
, toWindow
=windowid
)
52 """Test program: Open www.python.org in all windows, then revert"""
54 windows_and_versions
= list()
55 windows_and_urls
= map(lambda x
: (x
[0], geturl(x
[0])[0]), windows_and_versions
)
56 for id, version
in windows_and_versions
:
57 openurl('http://www.python.org/', windowid
=id)
58 print 'Type return to revert to old contents-'
60 for id, url
in windows_and_urls
:
63 if __name__
== '__main__':