【问题标题】:kivy doesn't show windowkivy不显示窗口
【发布时间】:2020-11-24 03:40:49
【问题描述】:

我使用这段代码,并在 py charm 上运行它

import kivy
from kivy.app import App
from kivy.uix.label import Label


class MyApp(App):
    def build(self):
        return Label(text="gw hidup")


if __name__ == "__main__":
    MyApp().run()

这是我运行后出来的

[INFO   ] [Logger      ] Record log in C:\Users\xeryd\.kivy\logs\kivy_20-08-04_7.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\Scripts\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App         ] Unable to get a Window, abort.

为什么会出现这种情况,我该怎么办?

this is my packages list

【问题讨论】:

标签: python pip pycharm kivy


【解决方案1】:

此解决方案可能会在 OSX 或 Win 上帮助您

#qpy:kivy
import kivy
kivy.require('1.10.1') # **REPLACE WITH CURRENT KIVY VERSION** To Get Rid Of This error--> [CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes


from kivy import Config
Config.set('graphics', 'multisamples', '0') # **To Get Rid Of The Open GL 2.0 Error**

【讨论】:

  • 对不起我还是个初学者
  • 在导入的最顶端@zidanhadipratama 然后继续其他导入,但确保在所有导入的最底部编写第二个配置导入。
【解决方案2】:

@zidanhadipratama

您的评论的答案,

# The Other Imports
import kivy
kivy.require('1.10.1')
from kivy.app import App
from kivy.uix.label import Label

# Make Sure This Is Always the last import
from kivy import Config
Config.set('graphics', 'multisamples', '0')


# Main Code
class MyApp(App):
    def build(self):
        return Label(text="Hello, World!")


# Run This Thing
if __name__ == "__main__":
    MyApp().run()

【讨论】:

    猜你喜欢
    • 2020-10-12
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多