1. <small id='rEpIa'></small><noframes id='rEpIa'>

    2. <tfoot id='rEpIa'></tfoot>

          <bdo id='rEpIa'></bdo><ul id='rEpIa'></ul>
      1. <legend id='rEpIa'><style id='rEpIa'><dir id='rEpIa'><q id='rEpIa'></q></dir></style></legend>
      2. <i id='rEpIa'><tr id='rEpIa'><dt id='rEpIa'><q id='rEpIa'><span id='rEpIa'><b id='rEpIa'><form id='rEpIa'><ins id='rEpIa'></ins><ul id='rEpIa'></ul><sub id='rEpIa'></sub></form><legend id='rEpIa'></legend><bdo id='rEpIa'><pre id='rEpIa'><center id='rEpIa'></center></pre></bdo></b><th id='rEpIa'></th></span></q></dt></tr></i><div id='rEpIa'><tfoot id='rEpIa'></tfoot><dl id='rEpIa'><fieldset id='rEpIa'></fieldset></dl></div>
      3. Python Spyder 初始化 Hello World Kivi 应用程序一次?

        时间:2023-10-10

        <small id='0XoDW'></small><noframes id='0XoDW'>

      4. <i id='0XoDW'><tr id='0XoDW'><dt id='0XoDW'><q id='0XoDW'><span id='0XoDW'><b id='0XoDW'><form id='0XoDW'><ins id='0XoDW'></ins><ul id='0XoDW'></ul><sub id='0XoDW'></sub></form><legend id='0XoDW'></legend><bdo id='0XoDW'><pre id='0XoDW'><center id='0XoDW'></center></pre></bdo></b><th id='0XoDW'></th></span></q></dt></tr></i><div id='0XoDW'><tfoot id='0XoDW'></tfoot><dl id='0XoDW'><fieldset id='0XoDW'></fieldset></dl></div>

              <legend id='0XoDW'><style id='0XoDW'><dir id='0XoDW'><q id='0XoDW'></q></dir></style></legend>
              <tfoot id='0XoDW'></tfoot>
                <tbody id='0XoDW'></tbody>
              • <bdo id='0XoDW'></bdo><ul id='0XoDW'></ul>

                  本文介绍了Python Spyder 初始化 Hello World Kivi 应用程序一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有谁知道为什么 Python 的 2.7 Spyder 只成功初始化 'Hello World' Kivy 应用程序一次,即按 F5 会带来窗口应用程序,但是当我关闭它并再次按 F5 时,它会显示以下错误:

                  Does anyone know why Python's 2.7 Spyder is successfully initializing the 'Hello World' Kivy app just once, i.e. hitting F5 brings the window app, but when I close it and hit F5 again, it says the following error:

                  [INFO              ] [Base        ] Start application main loop
                  [ERROR             ] [Base        ] No event listeners have been created
                  [ERROR             ] [Base        ] Application will leave
                  

                  但是,通过 Anacondas 命令提示符初始化时没有错误.

                  However, there is no error when initialized through Anacondas Command Prompt.

                  这是代码(与网站相同):

                  Here's the code (same as website):

                  from kivy.app import App
                  from kivy.uix.button import Button
                  
                  class TestApp(App):
                      def build(self):
                          return Button(text='Hello World')
                  
                  TestApp().run()
                  
                  if __name__ == '__main__':
                      TestApp().run()
                  

                  推荐答案

                  其实这个示例程序只是一个最小的结构,让你尝试如何以如此简单的方式创建交互式 UI.

                  Actually the sample program is just a minimum structure for you to try out how the interactive UI can be created in such a simple way.

                  而在TestApp中,它实际上并没有实现event listeners来处理close事件.当您创建实际项目时,您应该始终注意这一点.实际上,如果您仔细查看 logging,您会注意到错误已经在您关闭 TestApp 时发生,而不是在您重新启动"您 TestApp:

                  And the in TestApp, it actually didn't implment the event listerners to handle the close event. And when you create your actual project, you should always take care of that. Acually if you look at the logging carefully, you would notice that the error happens already when you close the TestApp, not when you "re-start" you TestApp:

                  [INFO              ] [Base        ] Leaving application in progress...
                  INFO:kivy:[Base        ] Leaving application in progress...
                  [INFO              ] [Base        ] Start application main loop
                  INFO:kivy:[Base        ] Start application main loop
                  [ERROR             ] [Base        ] No event listeners have been created
                  ERROR:kivy:[Base        ] No event listeners have been created
                  [ERROR             ] [Base        ] Application will leave
                  ERROR:kivy:[Base        ] Application will leave
                  

                  因此,对于您的情况,一个简单的解决方法是在 Console 面板中转到 Run->Configure,而不是选择 Execute in current Python or IPython console,你只需选择第二个选项,即Execute in a new dedicated Python console.在这种情况下,当您完成代码时,Python 将关闭当前内核.并且每当你运行你的代码时,Spyder 会自动为这个特定的脚本创建一个新的专用内核.

                  So for your case, the one simple work-around is that you go to Run->Configure, in the Console panel, instead of you choose to Execute in current Python or IPython console, you just choose the second option, which is Execute in a new dedicated Python console. In this case, where time your finished the code, the Python will close the current kernel. And whenever you run your code, Spyder will automatically create a new dedicated kernel for this particular script.

                  这篇关于Python Spyder 初始化 Hello World Kivi 应用程序一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用python更改kivy语言中标签的文本 下一篇:Kivy - 基础应用程序有奇怪的对齐方式

                  相关文章

                  最新文章

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

                • <small id='UH234'></small><noframes id='UH234'>

                  <legend id='UH234'><style id='UH234'><dir id='UH234'><q id='UH234'></q></dir></style></legend>
                        <bdo id='UH234'></bdo><ul id='UH234'></ul>

                      <tfoot id='UH234'></tfoot>