From: Mark A. <ack...@go...> - 2001-06-12 22:50:24
|
Anyone have experience running IE or netscape from within jython? I just need to start it with a url. Mark |
From: Andre B. <an...@bu...> - 2001-06-13 11:45:58
|
Hi Mark, This works, but I definitely think there should be something more elegant or more "Python" ;-) : ================================================ C:\>jython Jython 2.0 on java1.3.0_01 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> from java.lang import Runtime >>> rt=Runtime.getRuntime() >>> browser="C:/Program Files/Internet Explorer/iexplore.exe" >>> url="www.jython.org" >>> cmd="%s %s" % (browser, url) >>> rt.exec(cmd) java.lang.Win32Process@407527 >>> ================================================ I would prefer "a la Python": ================================================ ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import webbrowser >>> webbrowser.open_new("www.python.com") ================================================ Regards, Andre ----- Original Message ----- From: "Mark Ackerman" <ack...@go...> To: "Jython Users (E-mail)" <jyt...@li...> Cc: <ack...@go...> Sent: Tuesday, June 12, 2001 5:50 PM Subject: [Jython-users] running IE from within jython > Anyone have experience running IE or netscape from within jython? I just > need to start it with a url. > > Mark > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Glen S. <gl...@en...> - 2001-06-13 16:42:28
|
On Wed, 13 Jun 2001, Andre Burgaud wrote: > Hi Mark, > > This works, but I definitely think there should be something more elegant or > more "Python" ;-) : > webbrowser.py from java.lang import * class webbrowser: def __init__(self, browser_path): self.browser=browser_path def setURL(self,url): self.url = url def open_new(self): p = Runtime.getRuntime().exec("%s %s" % (self.browser, self.url)) p.waitFor() #if you wish to wait until the browser is closed moduleA.py from webbrowser import webbrowser if __name__=="__main__": wb = webbrowser("C:/Program Files/Internet Explorer/iexplore.exe") wb.open_new("http://www.jython.org") > ================================================ > C:\>jython > Jython 2.0 on java1.3.0_01 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>> from java.lang import Runtime > >>> rt=Runtime.getRuntime() > >>> browser="C:/Program Files/Internet Explorer/iexplore.exe" > >>> url="www.jython.org" > >>> cmd="%s %s" % (browser, url) > >>> rt.exec(cmd) > java.lang.Win32Process@407527 > >>> > ================================================ > > I would prefer "a la Python": > > ================================================ > ActivePython 2.1, build 210 ActiveState) > based on Python 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import webbrowser > >>> webbrowser.open_new("www.python.com") > ================================================ > > Regards, > > Andre > > > ----- Original Message ----- > From: "Mark Ackerman" <ack...@go...> > To: "Jython Users (E-mail)" <jyt...@li...> > Cc: <ack...@go...> > Sent: Tuesday, June 12, 2001 5:50 PM > Subject: [Jython-users] running IE from within jython > > > > Anyone have experience running IE or netscape from within jython? I just > > need to start it with a url. > > > > Mark > > > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > http://lists.sourceforge.net/lists/listinfo/jython-users > > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users -- Glen Starchman Enabled Ventures/Enabled Technology Group gl...@en... 206.234.7330 |
From: D-Man <ds...@ri...> - 2001-06-13 17:15:27
|
On Tue, Jun 12, 2001 at 03:50:19PM -0700, Mark Ackerman wrote: | Anyone have experience running IE or netscape from within jython? I just | need to start it with a url. There is a module in the standard library (of CPython anyays) that will exec a web browser on the user's system. Check it out and see if it does what you want and works with Jython. The other option is to try COM, but I have no experience with it nor do I have a clue how well Java supports COM on Windows (COM doesn't exist anywhere else). -D |
From: Matthew S. <m.s...@cs...> - 2001-06-13 17:42:34
|
I found the following tip on www.javaworld.com some time ago that I use all the time. It's a static class that invokes a browser like so BrowserControl.displayURL("http://www.javaworld.com"); The nice thing about it is that if there is a running instance then it will use that browser also it works on multiple platforms. Source code and the article can be found here http://www.javaworld.com/javaworld/javatips/jw-javatip66.html Shouldn't be any work at all just compile the class, import it and call the function from within Jython. Matt --=20 Matthew S. Shields BSc (hons), PhD student Parallel and Scientific Computation Group, Dept of Computer Science Cardiff University http://www.cs.cf.ac.uk/User/M.S.Shields/ M.S.Shields@(cs.cf.ac.uk|usa.net) ICQ# 99023784 =1B:wq |