Forum Archive

Modal mode for `webbrowser.open()`

marcus67

The module webbrowser offers the handy function open which allows opening a webpage as a tab page in the console. I would have expected that when using modal=True Pythonista would switch to the appropriate tab in the console which has just been loaded and let the user browse the web page. After the user presses "Done" Pythonista would return to the script (and the screen) that the call was made from. Unfortunately, this does not work for me. The web page is loaded alright, but the console is not shown. So there's no way for the user to see the page without stopping the running script. Is this intended? Thanks!

marcus67

Nobody answered so far. @omz: Could you help me with this, please? Thanks!

JonB

You might prefer to use a WebView, which you can pop up in a pover or sheet, that way you have control, plus your script could interact with the webview, or the webview delegate can accept callbacks from the webview, etc.

marcus67

@JonB Yes, I might try that. It just seemed so handy to use the existing feature... :-)

[deleted]

@marcus67 you could use this WebBrowser class, it has similar functions to the built in webrowser but is written in pure Ui. It can be used modally too.

marcus67

@JonB @omz Thanks for incorporating this suggestion into the latest test version. Works perfectly!