Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Using Bottle/Webbrowser in v1.5
-
I have a script written as a self-contained web app using bottle to serve the content and the integrated webbrowser to display it.
Pythonista v1.5 now shifts the display away from the webbrowser to the console whenever anything is written to the console. By default, bottle outputs log information to the console, which means the any navigation on the webapp shifts the display away.
As an FYI for anyone else with the issue, adding
quiet=True
tobottle.run()
eliminates the default console output in bottle, but anything your script outputs to the console will shift focus to the console.It would be nice if there was an option to prevent the console from stealing focus from the webbrowser.
-
As a workaround you could try changing "http://" to "safari-http://".
-
Thanks I hadn't really thought of this when I changed the web browser UI. I guess one solution could be to change the console's behavior, so that it console doesn't automatically get focussed when you're in a different tab (web browser or docs).
-
Yeah this is impacting me too. Most of my apps are using Bottle and dump logging /adhoc debug stuff to the console.
Bottle's quiet option helps.
Maybe a good time for me to move to a better way of debugging ... :)
Just checking out the rest of v1.5 now.
-
Another workaround... Run as a popover webview in a ui view.
-
I suppose you could also redirect
stdout
somehwere else while the script is running, that'll make sure that you won't have any kind of console output. Not the cleanest way to get rid of console output, but it should work. -
@omz:
Probably the best default behavior is to leave the user on whichever tab is currently active.
Other options would be:
- modify the icon of any non-active tab that has changed content so the user is aware and could switch to the display manually (as long as it's simply informative and not a blinking or other 'annoying' style that demands attention)
- add methods or options to the Pythonista iOS console/webbrowser modules to specify or force when and how switching between views is done.
In either case, I think the best default option is to remain on the current view.
The various workarounds listed above are all helpful. However, one of the benefits to writing a script as a self-contained webapp with bottle/webserver is that the same script will work on Windows, Mac, Linux and iOS (through Pythonista) with minimal or no modification -- the fewer workarounds and hacks needed for Pythonista, the better.