Skip to content
Related Articles
Open in App
Not now

Related Articles

How to exit a Kivy application using a button ?

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 15 Mar, 2021
Improve Article
Save Article

Kivy is a graphical user interface open-source Python library that allows you to develop multi-platform applications on Windows, macOS, Android, iOS, Linux, and Raspberry-Pi. In addition to the regular mouse and keyboard inputs, it also supports multitouch events. The applications made using Kivy will similar across all the platforms, but it also means that the application’s feel or look will differ from any native application.

In this article, we will develop a GUI window using kivy framework of python, and we will add a single button on the window which will close kivy application on click


  • Import kivy button
  • Import kivy app
  • Import kivy builder
  • Create App class
  • Return builder string
  • Run an instance of the class

Below is the implementation.


# importing button widget from kivy framework
from kivy.uix.button import Button
from import App
from kivy.core.window import Window
# 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 close_application(self):
        # closing application
        # removing window
    def build(self):
        return Builder.load_string("""
#:import C kivy.utils.get_color_from_hex
   # text which will appear on first button
   text:"Close App"
   on_release: app.close_application()
# running the application


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!