Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-10 Thread Roel Schroeven
Kent Johnson wrote:

 Terry Carroll wrote:
 
Is there any way, from within Python, to cause the default browser 
(Firefox, in my case) to be invoked with a specific URL?

I'd like to do something like (totally made-up name and syntax):

OpenBrowser(http://www.google.com/;)

and have a new browser window opened up pointing to Google.
 
 
import webbrowser
webbrowser.open(http://www.google.com/;)

Splendid! I've been looking for something like that too, but somehow 
that module escaped my attention. Thanks!

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread Kent Johnson
Terry Carroll wrote:
 Is there any way, from within Python, to cause the default browser 
 (Firefox, in my case) to be invoked with a specific URL?
 
 I'd like to do something like (totally made-up name and syntax):
 
 OpenBrowser(http://www.google.com/;)
 
 and have a new browser window opened up pointing to Google.

   import webbrowser
   webbrowser.open(http://www.google.com/;)

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread jfouhy
Quoting Terry Carroll [EMAIL PROTECTED]:

 Is there any way, from within Python, to cause the default browser 
 (Firefox, in my case) to be invoked with a specific URL?

If you're on Win32, try:

 import win32api
 win32api.ShellExecute(0, 'open', 'http://www.google.com/', None, '', 1)

Parameters in order: 
 - Handle to the parent window (0 for no parent)
 - Operation to perform (you can also use 'print', and maybe others?)
 - Name of the file/shortcut to execute
 - Optional parameters for the new process
 - Initial directory for the new process
 - Flag indicating if the new window should be shown or not.

[information from Mark Hammond's book]

Basically, this does the same thing as double-clicking on the file/shortcut in
Windows Explorer.

If you're on Linux, I'm not sure.  I think different distros / window managers
may have different ways of defining things like a default browser, or different
ways of getting at them.

And I don't know anything about Mac OS X :-)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread Terry Carroll
On Mon, 9 May 2005, Kent Johnson wrote:

import webbrowser
webbrowser.open(http://www.google.com/;)

Beautiful; just what I needed.  Thanks.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor