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 应用程序


- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01