問題描述
我只是在學習 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 應用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!