Open In App
Related Articles

How to make a Hyperlink in a Button in Kivy?

Improve Article
Save Article
Like Article

Kivy is a platform-independent GUI tool in Python. It can run on Android, IOS, Linux and Windows, etc. This is the only GUI library from python which can independently run on the android device even we can use it on Raspberry Pi also. If you are new to kivy you can learn from this link.

In this article, we will develop a GUI window using kivy framework of Python, and we will add a button on this window.  Usually what happens is we attach a method to a button and the whole method is defined in another python file but this time we will write the button code of python in the same kivy string.

Note: We are using the on_release event here with the button to make it functional. We can also use the on_press event also rather than the on_release event, both events can open the link, the only difference is on_release event will open the link when we release our finger from the button while on_press will open the link as soon as we touch the button. For using on_press event simply replace on_release with on_press.

Here, the IDE we are going to use is pycharm and the version of python we are going to use is python 3.6.



# importing button widget from kivy framework
from kivy.uix.button import Button
from import App
# importing builder from kivy
from kivy.lang import Builder
# this is the main class which will render the whole application
class uiApp(App):
    # method which will render our application
    def build(self):
        return Builder.load_string("""
    # text which will appear on button
    text:"click here to open google search"
        # importing webbrowser module
        import webbrowser
        # it will open google window in your browser'')
        print("see like this way you can write python supported code in kivy file")
# running the application


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 25 Feb, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials