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

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

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

      <tfoot id='aEu0w'></tfoot>

        如何分析 Kivy 应用程序?

        How can I profile a Kivy application?(如何分析 Kivy 应用程序?)

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

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

                1. <tfoot id='n9UT2'></tfoot>
                  <legend id='n9UT2'><style id='n9UT2'><dir id='n9UT2'><q id='n9UT2'></q></dir></style></legend>
                  本文介绍了如何分析 Kivy 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Kivy 构建游戏.我遇到了性能问题,所以我决定分析该程序.

                  I'm building a game using Kivy. I'm encountering performance issues so I decided to profile the program.

                  我尝试通过以下方式运行它:

                  I tried to run it by:

                  python -m cProfile main.py
                  

                  应用程序屏幕保持黑色.几秒钟后,一个异常使程序崩溃:

                  The application screen stays black. After several seconds, an exception crashes the program:

                   Traceback (most recent call last):
                     File "c:python27Lib
                  unpy.py", line 162, in _run_module_as_main
                       "__main__", fname, loader, pkg_name)
                     File "c:python27Lib
                  unpy.py", line 72, in _run_code
                       exec code in run_globals
                     File "c:python27LibcProfile.py", line 199, in <module>
                       main()
                     File "c:python27LibcProfile.py", line 192, in main
                       runctx(code, globs, None, options.outfile, options.sort)
                     File "c:python27LibcProfile.py", line 49, in runctx
                       prof = prof.runctx(statement, globals, locals)
                     File "c:python27LibcProfile.py", line 140, in runctx
                       exec cmd in globals, locals
                     File "main.py", line 26, in <module>
                       GameApp().run()
                     File "C:UsersAvivEnvsgamelibsite-packageskivyapp.py", line 828, in run
                       runTouchApp()
                     File "C:UsersAvivEnvsgamelibsite-packageskivyase.py", line 487, in runTouchApp
                       EventLoop.window.mainloop()
                     File "C:UsersAvivEnvsgamelibsite-packageskivycorewindowwindow_sdl2.py", line 619, in mainloop
                       self._mainloop()
                     File "C:UsersAvivEnvsgamelibsite-packageskivycorewindowwindow_sdl2.py", line 403, in _mainloop
                       x, y = self._fix_mouse_pos(x, y)
                     File "C:UsersAvivEnvsgamelibsite-packageskivycorewindowwindow_sdl2.py", line 358, in _fix_mouse_pos
                       self.mouse_pos = x, self.system_size[1] - y
                     File "kivyproperties.pyx", line 408, in kivy.properties.Property.__set__ (kivyproperties.c:5114)
                     File "kivyproperties.pyx", line 446, in kivy.properties.Property.set (kivyproperties.c:5876)
                     File "kivyproperties.pyx", line 501, in kivy.properties.Property.dispatch (kivyproperties.c:6557)
                     File "kivy\_event.pyx", line 1224, in kivy._event.EventObservers.dispatch (kivy\_event.c:13497)
                     File "kivy\_event.pyx", line 1130, in kivy._event.EventObservers._dispatch (kivy\_event.c:12696)
                     File "gameopening_screen.py", line 22, in _on_mouse_pos
                       if self.ids.start_button.collide_point(*position):
                     File "kivyproperties.pyx", line 757, in kivy.properties.ObservableDict.__getattr__ (kivyproperties.c:11882)
                   AttributeError: 'super' object has no attribute '__getattr__'
                  

                  为什么会发生这种情况,如何分析我的 Kivy 应用程序?

                  Why is this happening, and how can I profile my Kivy application?

                  推荐答案

                  kivy 文档声明您无法从命令行执行此操作.

                  The kivy docs state that you cannot do it from the command line.

                  https://kivy.org/docs/api-kivy.app.html

                  你可以这样做:(从文档复制)

                  You can do it like this: (copied from the docs)

                  import cProfile
                  
                  class MyApp(App):
                      def on_start(self):
                          self.profile = cProfile.Profile()
                          self.profile.enable()
                  
                      def on_stop(self):
                          self.profile.disable()
                          self.profile.dump_stats('myapp.profile')
                  

                  这篇关于如何分析 Kivy 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)

                    <tbody id='Jpucq'></tbody>

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

                    <tfoot id='Jpucq'></tfoot>

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