How to exit a Kivy application using a button(如何使用按钮退出 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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用按钮退出 Kivy 应用程序


基础教程推荐
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01