How can I make a link that opens a web browser in Kivy? I've tried just putting the url in a label, but of course that doesn't work. I'd like it to work on the android app specifically and allow users to click it to open a web browser to that link.
Use webbrowser, it works already on Desktop, and our toolchain for iOS / Android have implemented a backend for it. Ie, use it, it will just works everywhere:
import webbrowser
webbrowser.open("http://kivy.org/")
You'll need to make the text clickable with the ref
markup tag (see the markup documentation for details), and then bind it to a function that opens a web browser at the right page. On the desktop you could use the webbrowser module, on android you'll want to call android's normal functions with pyjnius. There's a prewritten example of how to do so here.
This is something that will probably go in the plyer project, which would provide a cross-platform way to open the right web browser on any supported system with a single python interface. It's not added yet though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With