Search code examples
pythonhyperlinkmarkupkivyref

Kivy hyperlink in kv file


I am making a mockup of an app just for testing purposes. I am new to kivy and need some help. I want my label to have the text 'Need Help' and when pressed on want it to act as a hyper link. I have a simple class

class LoginScreen(BoxLayout):
    def login(self, *args):
        print 'You logged in'

The part of my kv file I am having trouble with is the label in my LoginScreen.

Label:
    id: need_help_link
    font_size: 20
    markup: True
    text: 'Need help [ref=some]someweblink[/ref]'

I want the label to read "Need help" and the hyper link to be some website, but when I run this code the label reads everything so I get "Need help [ref=some]someweblink[/ref]" printed on my app. I know I am doing something wrong, but not sure what. Any help would be greatly appreciated.


Solution

  • Label:
        id: need_help_link
        font_size: 20
        markup: True
        text: 'Need help [ref=some]someweblink[/ref]'
        on_ref_press:
            import webbrowser
            webbrowser.open('http://google.com')