omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Webbrowser get and register

    Pythonista
    5
    9
    7098
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lvinci
      lvinci last edited by

      Webbrowser register and get do not to seem to be valid attributes

      webbrowser.register('chrome')
      webbrowser.get('chrome')

      Is there a way to open a specific browser?

      Tia

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        webbrowser.open(url[, modal=False])

        If you want to open http or https URLs in Safari instead of the built-in browser, you can replace http(s) with safari-http(s) in your URL, e.g. ‘safari-http://google.com’.

        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          To open a URL in Chrome on iOS, you can simply replace http:// with googlechrome:// in the URL (https:// becomes googlechromes://)

          Example: webbrowser.open('googlechrome://apple.com').

          1 Reply Last reply Reply Quote 0
          • lsloan
            lsloan last edited by lsloan

            That works in programs when run directly from Pythonista (Python 2.7), but not if the program is run from another app via the sharing extension.

            I saw another post in the forum that showed using PyObjC Objective-C via objc_util to open URLs in the default browser (Safari), but I don't know how to make it open them in Chrome instead. (Again, via the app sharing extension.)

            1 Reply Last reply Reply Quote 0
            • omz
              omz last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • omz
                omz last edited by

                @lsloan Example:

                from objc_util import *
                app = UIApplication.sharedApplication()
                app.openURL_(nsurl('googlechrome://apple.com'))
                
                1 Reply Last reply Reply Quote 1
                • lsloan
                  lsloan last edited by

                  Thanks for the clarification, @omz. Shortly before you replied, I thought that I should just try that and it worked.

                  When I asked about it, I thought maybe it would be necessary to specify Chrome as an argument to sharedApplication() or some other method. I'm glad it's really just that simple.

                  I'd like to suggest that the Pythonista documentation be updated to explain that using webbrowser.open() doesn't work to open other applications via the application sharing extension/mechanism. That is, add a note about that and give an example of the UIApplication.sharedApplication() method that works instead. These pages seem like good places for this update:

                  • http://omz-software.com/pythonista2/docs/ios/urlscheme.html#launching-other-apps
                  • http://omz-software.com/pythonista2/docs/library/webbrowser.html#webbrowser.open

                  (And the corresponding documentation for the newer Pythonista.)

                  If the documentation had mentioned this already, it would literally have saved me hours of frustration. I thought I was using webbrowser.open() incorrectly.

                  Also, what's happened with the "list of third-party applications that have URL schemes" that was available at http://handleopenurl.com/? It appears to be defunct. Is there a replacement resource?

                  1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp last edited by

                    It was in the doc

                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp last edited by

                      To launch an app, I use th Launcher (free) app which gives a list of all apps it can launch via their URL.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors