加载多个文件时出错?
getting an error of loading multiple files?
错误
[INFO ] [Base ] Leaving application in progress...
[WARNING] [Lang ] The file e:\school_proj\final_with_settings\layout.kv is loaded multiples times, you might have unwanted behaviors.
[INFO ] [Base ] Start application main loop
False
True
UPDATED
[INFO ] [Base ] Leaving application in progress...
所以,我接受了一些用户输入然后进行更改,我必须重新启动应用程序。
同样,我在互联网上找到了这段代码:
def restart(self):
self.root.clear_widgets()
self.stop()
return StonkkApp().run()
这位于 MDApp class
.py代码
class StonkkApp(MDApp):
def build(self):
self.icon = f'{cur_file_path}/stonkss.png'
screen = Builder.load_file('layout.kv')
self.theme_cls.theme_style = theme
self.theme_cls.primary_palette = 'Gray'
return screen
def restart(self):
self.root.clear_widgets()
self.stop()
return StonkkApp().run()
然后报错
Full Traceback:
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.1.0.dev0, git-143ba31, 20210630
[INFO ] [Python ] v3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.5.13399 Compatibility Profile Context
15.201.1151.1008'>
[INFO ] [GL ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO ] [GL ] OpenGL parsed version: 4, 5
[INFO ] [GL ] Shading version <b'4.40'>
[INFO ] [GL ] Texture max size <16384>[INFO ] [GL ] Texture max units <18>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Base ] Start application main loop
False
True
UPDATED
Saving changes.
current color and type of plot is , . app mode is Light
[INFO ] [Base ] Leaving application in progress...
[WARNING] [Lang ] The file e:\school_proj\final_with_settings\layout.kv is loaded multiples times, you might have unwanted behaviors.
[INFO ] [Base ] Start application main loop
False
True
UPDATED
[INFO ] [Base ] Leaving application in progress...
这个错误是在我启动 运行 重启代码后出现的。
解决方案:
Builder.unload_file('Layout.kv')
只需添加到 restart() 函数的开头。
当您重新启动 App
时,build()
方法正在重新加载行中的 kv
文件:
screen = Builder.load_file('layout.kv')
有关如何防止加载 kv
文件两次的想法,请参阅 。
错误
[INFO ] [Base ] Leaving application in progress...
[WARNING] [Lang ] The file e:\school_proj\final_with_settings\layout.kv is loaded multiples times, you might have unwanted behaviors.
[INFO ] [Base ] Start application main loop
False
True
UPDATED
[INFO ] [Base ] Leaving application in progress...
所以,我接受了一些用户输入然后进行更改,我必须重新启动应用程序。
同样,我在互联网上找到了这段代码:
def restart(self):
self.root.clear_widgets()
self.stop()
return StonkkApp().run()
这位于 MDApp class
.py代码
class StonkkApp(MDApp):
def build(self):
self.icon = f'{cur_file_path}/stonkss.png'
screen = Builder.load_file('layout.kv')
self.theme_cls.theme_style = theme
self.theme_cls.primary_palette = 'Gray'
return screen
def restart(self):
self.root.clear_widgets()
self.stop()
return StonkkApp().run()
然后报错
Full Traceback:
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.1.0.dev0, git-143ba31, 20210630
[INFO ] [Python ] v3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.5.13399 Compatibility Profile Context
15.201.1151.1008'>
[INFO ] [GL ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO ] [GL ] OpenGL parsed version: 4, 5
[INFO ] [GL ] Shading version <b'4.40'>
[INFO ] [GL ] Texture max size <16384>[INFO ] [GL ] Texture max units <18>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Base ] Start application main loop
False
True
UPDATED
Saving changes.
current color and type of plot is , . app mode is Light
[INFO ] [Base ] Leaving application in progress...
[WARNING] [Lang ] The file e:\school_proj\final_with_settings\layout.kv is loaded multiples times, you might have unwanted behaviors.
[INFO ] [Base ] Start application main loop
False
True
UPDATED
[INFO ] [Base ] Leaving application in progress...
这个错误是在我启动 运行 重启代码后出现的。
解决方案:
Builder.unload_file('Layout.kv')
只需添加到 restart() 函数的开头。
当您重新启动 App
时,build()
方法正在重新加载行中的 kv
文件:
screen = Builder.load_file('layout.kv')
有关如何防止加载 kv
文件两次的想法,请参阅