1. <tfoot id='7vlgk'></tfoot>

        <small id='7vlgk'></small><noframes id='7vlgk'>

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

      1. <legend id='7vlgk'><style id='7vlgk'><dir id='7vlgk'><q id='7vlgk'></q></dir></style></legend>
          <bdo id='7vlgk'></bdo><ul id='7vlgk'></ul>

      2. Python/Kivy App 只运行一次

        时间:2023-10-10

            <legend id='5v9In'><style id='5v9In'><dir id='5v9In'><q id='5v9In'></q></dir></style></legend>
              <tbody id='5v9In'></tbody>
            <i id='5v9In'><tr id='5v9In'><dt id='5v9In'><q id='5v9In'><span id='5v9In'><b id='5v9In'><form id='5v9In'><ins id='5v9In'></ins><ul id='5v9In'></ul><sub id='5v9In'></sub></form><legend id='5v9In'></legend><bdo id='5v9In'><pre id='5v9In'><center id='5v9In'></center></pre></bdo></b><th id='5v9In'></th></span></q></dt></tr></i><div id='5v9In'><tfoot id='5v9In'></tfoot><dl id='5v9In'><fieldset id='5v9In'></fieldset></dl></div>
          1. <small id='5v9In'></small><noframes id='5v9In'>

            <tfoot id='5v9In'></tfoot>
                <bdo id='5v9In'></bdo><ul id='5v9In'></ul>

                1. 本文介绍了Python/Kivy App 只运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Anaconda 平台的 Spyder IDE 运行一个非常简单的 python (3.5) 脚本.

                  I'm running a very simple python (3.5) script using Spyder IDE from Anaconda platform.

                  from kivy.app import App
                  from kivy.uix.label import Label
                  from kivy.uix.gridlayout import GridLayout
                  from kivy.uix.textinput import TextInput
                  
                  class LoginScreen(GridLayout):
                      def __init__(self, **kwargs):
                          super(LoginScreen,self).__init__(*kwargs)
                          self.cols = 2
                          self.add_widget(Label(text='Username'))
                          self.username = TextInput(multiline=False)
                          self.add_widget(self.username)
                      
                          self.add_widget(Label(text='Password'))
                          self.password = TextInput(multiline=False, password=True)
                          self.add_widget(self.password)
                  
                  class TestApp(App):
                      def build(self):
                          return LoginScreen()
                  
                  if __name__ == '__main__':
                      TestApp().run()
                  

                  应用程序"第一次尝试运行良好(它还没有做任何事情,只是启动),但是当我尝试再次启动它时,我收到以下错误消息:

                  "App" runs fine on the first try (it doesn't do anything yet, just launches), but when I'm trying to launch it again, I'm getting a following error message:

                  [INFO] [Base] 启动应用程序主循环

                  [INFO ] [Base ] Start application main loop

                  [ERROR] [Base] 没有创建事件监听器

                  [ERROR ] [Base ] No event listeners have been created

                  [ERROR ] [Base ] 应用程序将离开

                  [ERROR ] [Base ] Application will leave

                  让它再次工作的唯一方法是重新启动在 Spyder 中运行的内核.之后,应用程序将再次启动(但仅启动一次).

                  The only way to make it work again is to restart the kernel running in Spyder. After that the app will launch once again (but only once).

                  我注意到,在第一次运行时,Ipython 控制台会首先打印很多其他信息,在启动应用程序主循环"之前.行,在那些失败的运行中,我只得到上面那 3 行.

                  What I've noticed is that on the first run, the Ipython console would print a lot of other info first, before the "Start application main loop" line, and on those failed runs, I'm getting just those 3 lines above.

                  有谁知道我做错了什么?非常感谢您的帮助.

                  Does anyone know what I'm doing wrong? Many thanks for any help.

                  推荐答案

                  没有那么多与 Kivy 相关的问题.Spyder 可能会在内存中保留旧的东西?尝试在一个简单的解释器中逐行键入您的代码.然后关闭应用程序并再次尝试输入 TestApp().run() - 相同的三行.

                  Not that much Kivy-related problem. Spyder probably keeps old stuff in memory? Try in a simple interpreter type your code line by line. Then close the app and try again typing TestApp().run() - the same three lines.

                  这样你会看到如果旧的东西(变量、类、任何仍然可以访问的东西)存在,Kivy 将不允许你启动应用程序(对我来说仍然是一个谜,可能是因为与窗口相关代码?)

                  This way you'll see that if the old stuff (variables, classes, whatever is still accessible) is present, Kivy won't allow you to launch the app (still a mistery to me, maybe because of window-related code?)

                  如果 Spyder 中有什么东西可以从内存中清除旧的东西,那么在每次 Kivy 退出后设置它,你应该很高兴.

                  If there is something in Spyder to flush old stuff from memory, then set it after each Kivy exit and you should be good to go.

                  这篇关于Python/Kivy App 只运行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Kivy - 在 .py 文件中的另一个屏幕中使用来自一个 下一篇:如何在kivy Pong球赛中从另一个类中调用一个类的

                  相关文章

                  最新文章

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

                    • <bdo id='chFaY'></bdo><ul id='chFaY'></ul>

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

                    1. <legend id='chFaY'><style id='chFaY'><dir id='chFaY'><q id='chFaY'></q></dir></style></legend>