简体   繁体   中英

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.

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM