|
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
|