如何使用按钮退出 Kivy 应用程序 [英] How to exit a Kivy application using a button

查看:37
本文介绍了如何使用按钮退出 Kivy 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习 Python 和 Kivy 框架.我似乎找不到任何能够使用链接到按钮的代码优雅地退出 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.

我发现了这样的 Kivy 代码片段

I have found Kivy code snippets like this

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

但没有实现 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.

我已阅读 Android 和 iOS 样式指南声明程序不会以编程方式退出并让操作系统处理它,但我正在开发全屏无边框桌面应用程序,并且需要一种通过按下按钮退出程序的方法.

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.

推荐答案

尝试使用 App.get_running_app().stop().
有关详细信息,请阅读 Kivy 文档文章为函数.

这篇关于如何使用按钮退出 Kivy 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆