Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exit a Kivy application using a button

Tags:

python

kivy

I'm just learning Python and the Kivy framework. I can't seem to find any specific complete examples of being able to gracefully exit a Kivy app using code linked to a button.

I have found Kivy code snippets like this

Button:
    id:btnExit
    text:"Exit"
    on_press: app.Exit()

But not any matching code that implements the app.Exit() call. Everything I've tried stops code execution but doesn't clean up the program window.

I've read that Android and iOS style guides state that a program is not to programmatically exit and let the OS handle it but I am developing fullscreen borderless Desktop app and need a way to exit the program with a button press.

like image 370
Ballew Avatar asked Sep 06 '15 16:09

Ballew


People also ask

How do I exit KIVY?

Try using App. get_running_app(). stop() . For more details, read the Kivy documentation article for the function.

Does KIVY have a GUI?

Build and distribute beautiful Python cross-platform GUI apps with ease. Kivy runs on Android, iOS, Linux, macOS and Windows.

What is KIVY with respect to Python?

Kivy is an opensource multi-platform GUI development library for Python and can run on iOS, Android, Windows, OS X, and GNU/Linux. It helps develop applications that make use of innovative, multi-touch UI.


1 Answers

Use App.stop(*largs):

Button:
    id: btnExit
    text: "Exit"
    on_press: app.stop() 
like image 120
Ruben G Avatar answered Sep 22 '22 13:09

Ruben G