How to exit a Kivy application using a button ?
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
Approach:
- 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.
Python3
from kivy.uix.button import Button
from kivy.app import App
from kivy.core.window import Window
from kivy.lang import Builder
class uiApp(App):
def close_application( self ):
App.get_running_app().stop()
Window.close()
def build( self ):
return Builder.load_string(
)
uiApp().run()
|
Output:
Last Updated :
15 Mar, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...