I think this might be what you want:
import webbrowser
browser = ' '.join([
"chrome",
"--chrome-frame",
"--window-size=800,600",
"--window-position=240,80",
"--app=%s &",
])
webbrowser.get(browser).open('http://www.paypal.com/buyProductURL')
The %s
parameter is the url used by the module. It's required to call the browser as a command with arguments.
Here are some answers on how to call chrome in the command line.
If you require portability with the same behavior across all browsers it seems to be unattainable to me. I don't think you have an alternative here unless you ship the browser with your code or write more code for browser alternatives like chrome, firefox
and opera
. I wrote a code where it would work as a popup-like on chrome and chromium and as a tab open on other browsers:
import webbrowser
try_browsers = {
"chrome": [
"chrome",
"--chrome-frame",
"--window-size=800,600",
"--window-position=240,80",
"--app=%s &",
],
}
try_browsers['chromium'] = try_browsers['chrome'][:]
try_browsers['chromium'][0] = 'chromium'
URL = 'http://www.paypal.com/buyProductURL'
for browser in try_browsers.values():
if webbrowser.get(' '.join(browser)).open(URL):
break
else:
webbrowser.open(URL)