[Tutor] Re: Webbrowser
Andrei
project5 at redrival.net
Mon Sep 8 21:17:10 EDT 2003
Danny Yoo wrote:
>
> Hmmm... the webbrowser module does the following checks on a Unix
> environment:
>
<snip>
>
> According to the code above, it should have been able to find KDE's
> Konqueror browser fine, as long as:
>
> 1. os.environ.get('DISPLAY') is some kind of true value, and
> 2. kfm or konqueror can be found by the system.
>
> So you may want to check those first.
I'll look at those when I boot in Linux. The annoying bit is that in a
standard installation of a popular, modern distro (Mandrake), the Python
module doesn't work out of the box. Konqueror is of course present, as
well as Mozilla and the Gnome browser (name escapes me atm).
>>On a sidenote: is there any support for browsers which have tabs (as in:
>>open in a new tab)?
>
>
> Good question! I'm not sure how to do this platform-independently yet,
> but Mozilla does support it:
>
> http://www.mozilla.org/docs/command-line-args.html
>
> through the 'new-tab' option. To get this to work, we'd probably have to
> modify the 'Netscape' handler within webbrowser.py. Here's one way we
> might be able to do it:
>
<snip code>
>
> This modification augments the 'new' keyword parameter so that it can take
> in 'tab', in which case it'll try to open using the 'new-tab' option:
>
> ###
> import webbrowser_modified
> webbrowser_modified.open('http://python.org', new='tab')
> ###
>
>
> Can't test this on my end, since I'm running on Safari. Can someone check
> to see if this works? If this were polished up, it might make a nice
> submission to Sourceforge... *grin*
>
Thanks, I'll test that too.
=====
Scot W. Stevenson wrote:
>
> I used the browser module exactly once, and I started it off with
>
> try:
> self.mybrowser = webbrowser.get()
> except TypeError:
> [Say you can't find the browser]
>
> I'm not sure if you did something like that before the part of the
code that
> you mentioned. The docs say you can "register" a browser; if all else
fails,
> maybe that would be the way to go.
Yes, I use that method elsewhere in my code and use a different display
method (plain text in a message window instead of HTML). However, in
this case I don't want that. I *must* have the browser.
Andrei
=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
ernq gur yvfg, fb gurer'f ab arrq gb PP.
More information about the Tutor
mailing list