久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='VjIJP'><style id='VjIJP'><dir id='VjIJP'><q id='VjIJP'></q></dir></style></legend>

    <tfoot id='VjIJP'></tfoot>
    <i id='VjIJP'><tr id='VjIJP'><dt id='VjIJP'><q id='VjIJP'><span id='VjIJP'><b id='VjIJP'><form id='VjIJP'><ins id='VjIJP'></ins><ul id='VjIJP'></ul><sub id='VjIJP'></sub></form><legend id='VjIJP'></legend><bdo id='VjIJP'><pre id='VjIJP'><center id='VjIJP'></center></pre></bdo></b><th id='VjIJP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VjIJP'><tfoot id='VjIJP'></tfoot><dl id='VjIJP'><fieldset id='VjIJP'></fieldset></dl></div>
        <bdo id='VjIJP'></bdo><ul id='VjIJP'></ul>

        <small id='VjIJP'></small><noframes id='VjIJP'>

        如何在 kivy 應用程序退出時運行方法

        How to run a Method on the exit of a kivy app(如何在 kivy 應用程序退出時運行方法)
          <bdo id='lMXtz'></bdo><ul id='lMXtz'></ul>
        • <tfoot id='lMXtz'></tfoot>

          <small id='lMXtz'></small><noframes id='lMXtz'>

            <tbody id='lMXtz'></tbody>
        • <i id='lMXtz'><tr id='lMXtz'><dt id='lMXtz'><q id='lMXtz'><span id='lMXtz'><b id='lMXtz'><form id='lMXtz'><ins id='lMXtz'></ins><ul id='lMXtz'></ul><sub id='lMXtz'></sub></form><legend id='lMXtz'></legend><bdo id='lMXtz'><pre id='lMXtz'><center id='lMXtz'></center></pre></bdo></b><th id='lMXtz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='lMXtz'><tfoot id='lMXtz'></tfoot><dl id='lMXtz'><fieldset id='lMXtz'></fieldset></dl></div>
          • <legend id='lMXtz'><style id='lMXtz'><dir id='lMXtz'><q id='lMXtz'></q></dir></style></legend>

                  本文介紹了如何在 kivy 應用程序退出時運行方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想在用戶嘗試退出應用程序時運行一個方法,有點像您確定要退出"或您要保存文件"類型的消息,只要用戶嘗試退出點擊窗口頂部的退出按鈕退出

                  I would like to run a Method when the user tries to exit the app , kind of like a "are you sure you want to exit" or "Do you want to save the file" type of message whenever the user tries to exit by clicking the Exit button on top of the window

                  類似的東西on_quit: app.root.saveSession()

                  推薦答案

                  如果您希望您的應用程序在 GUI 關閉后簡單地運行,最簡單和最小的方法是在 TestApp().run().run() 創建了一個無限循環,它還會清除 kivy 中的任何事件數據,因此它不會掛起.一旦窗口/gui 實例死亡,那個無限循環就會中斷.因此,之后的任何代碼都只會在 GUI 死掉之后才會執行.

                  If you want your application to simply run things after the GUI has closed, the easiest and smallest approach would be to place any exit code after TestApp().run(). run() creates a endless loop which also clears any event-data from within kivy so it doesn't hang. That endless loop breaks as soon as the window/gui instance dies. So there for, any code after will execute only after the GUI dies too.

                  如果您想創建一個優雅的 GUI 關閉,例如套接字關閉事件或彈出窗口詢問用戶是否真的想要這樣做,那么為 on_request_close 事件創建一個鉤子是要走的路:

                  If you want to create a graceful shutdown of the GUI with for instance socket-closing events or a popup asking the user if that's what they really want to do, then creating a hook for the on_request_close event is the way to go:

                  from kivy.config import Config
                  Config.set('kivy', 'exit_on_escape', '0')
                  
                  from kivy.app import App
                  from kivy.uix.label import Label
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.uix.button import Button
                  from kivy.uix.popup import Popup
                  from kivy.core.window import Window
                  
                  
                  class ChildApp(App):
                  
                      def build(self):
                          Window.bind(on_request_close=self.on_request_close)
                          return Label(text='Child')
                  
                      def on_request_close(self, *args):
                          self.textpopup(title='Exit', text='Are you sure?')
                          return True
                  
                      def textpopup(self, title='', text=''):
                          """Open the pop-up with the name.
                  
                          :param title: title of the pop-up to open
                          :type title: str
                          :param text: main text of the pop-up to open
                          :type text: str
                          :rtype: None
                          """
                          box = BoxLayout(orientation='vertical')
                          box.add_widget(Label(text=text))
                          mybutton = Button(text='OK', size_hint=(1, 0.25))
                          box.add_widget(mybutton)
                          popup = Popup(title=title, content=box, size_hint=(None, None), size=(600, 300))
                          mybutton.bind(on_release=self.stop)
                          popup.open()
                  
                  
                  if __name__ == '__main__':
                      ChildApp().run()
                  

                  感謝創建 pythonic64="noreferrer">gist 回到 issue 時的主題.

                  Courtesy of pythonic64 who created a gist on the topic in a issue way back when.

                  這篇關于如何在 kivy 應用程序退出時運行方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                  1. <legend id='Pe25u'><style id='Pe25u'><dir id='Pe25u'><q id='Pe25u'></q></dir></style></legend>
                  2. <small id='Pe25u'></small><noframes id='Pe25u'>

                  3. <tfoot id='Pe25u'></tfoot>
                      <bdo id='Pe25u'></bdo><ul id='Pe25u'></ul>

                          <tbody id='Pe25u'></tbody>

                          <i id='Pe25u'><tr id='Pe25u'><dt id='Pe25u'><q id='Pe25u'><span id='Pe25u'><b id='Pe25u'><form id='Pe25u'><ins id='Pe25u'></ins><ul id='Pe25u'></ul><sub id='Pe25u'></sub></form><legend id='Pe25u'></legend><bdo id='Pe25u'><pre id='Pe25u'><center id='Pe25u'></center></pre></bdo></b><th id='Pe25u'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Pe25u'><tfoot id='Pe25u'></tfoot><dl id='Pe25u'><fieldset id='Pe25u'></fieldset></dl></div>
                            主站蜘蛛池模板: 九九在线精品视频 | 国产网站在线免费观看 | 亚洲成人精品在线观看 | 久久丝袜 | 日韩精品一区二区三区中文在线 | 国产精品福利视频 | 日韩一级 | 久久里面有精品 | 精品日韩| 国产电影一区二区在线观看 | 久久国产综合 | 免费一级片 | 美女视频黄的免费 | 欧美一区二区三区小说 | 免费亚洲婷婷 | 成人在线一区二区三区 | 亚洲一区有码 | 久久五月婷| 青青久草 | 岛国午夜 | 欧美激情综合 | 国产免费播放视频 | 在线观看你懂的网站 | 狠狠草视频| 日本久久精品视频 | 精品久久久久久国产 | 在线欧美视频 | www天天操 | 国产特级毛片 | 嫩呦国产一区二区三区av | 欧美日韩91| 欧美1区2区 | 91一区二区在线观看 | 99福利视频 | 国产精品久久久爽爽爽麻豆色哟哟 | 另类专区成人 | 久久久久亚洲精品 | 国产精品无码永久免费888 | 成人午夜激情 | 精精国产xxxx视频在线 | 婷婷在线视频 |