python / cpython

The Python programming language
https://www.python.org
Other
63.53k stars 30.43k forks source link

Opening a new unfocused tab in Chrome with webbrowser.open #92683

Open fredericomattos opened 2 years ago

fredericomattos commented 2 years ago

OS → Microsoft Windows 11 Chrome Version → 101.0.4951.54 (official version) 64 bits

I have Google website open and I want to open the Stackoverflow website in a new tab but the screen keeps showing the Google website.

All possible combinations I've tried to use but the page still opens and pulls the focus to it, my attempts were:

sof = 'https://stackoverflow.com'
webbrowser.open(sof, new=0, autoraise=False)
webbrowser.open(sof, new=2, autoraise=False)
webbrowser.open(sof, new=0, autoraise=True)
webbrowser.open(sof, new=2, autoraise=True)

All indications of use for such a function, lead me to the webbrowser + autoraise, I believe there is a problem.

VBPROGER commented 2 years ago

I had same problem.

hugovk commented 2 years ago

What versions of Python have you tried?

fredericomattos commented 2 years ago

What versions of Python have you tried?

@hugovk I tried to use in version 3.9.6 64-bit and in version 3.10.4 64-bit

hugovk commented 2 years ago

Thanks. At least I can't reproduce on macOS with Python 3.10.4.

NewUserHa commented 2 years ago

It seems that new and autoraise parameters are useable only for some browser on darwin or *nix. according https://github.com/python/cpython/blob/main/Lib/webbrowser.py#L604-L615 and https://github.com/python/cpython/blob/main/Lib/webbrowser.py#L159-L203

Maybe needs document this?

RRaphaell commented 2 years ago

did you solve that problem?