Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a hyperlink in kivy?

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.

like image 390
PoisonRain Avatar asked Dec 08 '22 09:12

PoisonRain


2 Answers

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/")
like image 183
tito Avatar answered Mar 08 '23 08:03

tito


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.

like image 41
inclement Avatar answered Mar 08 '23 08:03

inclement