Opening a webpage in the background via webbrowser.open()

Vlastimil Brom vlastimil.brom at gmail.com
Fri Oct 8 22:11:49 CEST 2010


2010/10/7  <python at bdurham.com>:
> Python 2.7 (32-bit/Windows): Is there a way to use webbrowser.open() to open
> a web page in the default browser, but in the background, so that the
> application making the webbrowser.open() call remains the active
> application?
>
> Thank you,
> Malcolm
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
It seems, there might not be a straightforward way for doing this.
As you probably found out, webbrowser.open has a parameter "autoraise"
 just for specifying this behaviour:
webbrowser.open(url[, new=0[, autoraise=True]])
however, the sidenote in the docs also seems to apply:
"If autoraise is True, the window is raised if possible (note that
under many window managers this will occur regardless of the setting
of this variable)."
http://docs.python.org/library/webbrowser.html#webbrowser.open

For me (win XP, python 2.5.4) the browser window is always raised
after this call, regardless the autoraise option.
Possibly, if you are using a gui app, the focus can be maintained form
there, in order to avoid activating the browser, otherwise it might be
more complicated. (maybe the pywin package might have some means for
achieving  this?)

vbr



More information about the Python-list mailing list