Kivy hyperlink in kv file

2019-08-26 02:30发布

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.

1条回答
老娘就宠你
2楼-- · 2019-08-26 02:35
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')
查看更多
登录 后发表回答