为什么kivy在代码启动时给出错误?

时间:2019-11-12 19:32:52

标签: python python-3.x kivy

我成功下载了kivy。 当我尝试使用在原始kivy基础网站上找到的以下命令启动kivy窗口时:

import kivy

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


class MyApp(App):

    def build(self):
        return Label(text='Hello world')


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

出现错误:

ArgumentError                             Traceback (most recent call last)
D:\Anaconda\lib\site-packages\kivy\core\window\window_sdl2.py in mainloop(self)
    746             try:
--> 747                 self._mainloop()
    748             except BaseException as inst:

D:\Anaconda\lib\site-packages\kivy\core\window\window_sdl2.py in _mainloop(self)
    478     def _mainloop(self):
--> 479         EventLoop.idle()
    480 

D:\Anaconda\lib\site-packages\kivy\base.py in idle(self)
    361             Logger.error('Base: Application will leave')
--> 362             self.exit()
    363             return False

D:\Anaconda\lib\site-packages\kivy\base.py in exit(self)
    374         '''Close the main loop and close the window.'''
--> 375         self.close()
    376         if self.window:

D:\Anaconda\lib\site-packages\kivy\base.py in close(self)
    171         self.quit = True
--> 172         self.stop()
    173         self.status = 'closed'

D:\Anaconda\lib\site-packages\kivy\base.py in stop(self)
    183         for provider in reversed(self.input_providers[:]):
--> 184             provider.stop()
    185             if provider in self.input_providers_autoremove:

D:\Anaconda\lib\site-packages\kivy\input\providers\wm_pen.py in stop(self)
    110             self.pen = None
--> 111             SetWindowLong_WndProc_wrapper(self.hwnd, self.old_windProc)
    112 

D:\Anaconda\lib\site-packages\kivy\input\providers\wm_common.py in _closure(hWnd, wndProc)
    121         def _closure(hWnd, wndProc):
--> 122             oldAddr = func(hWnd, GWL_WNDPROC, cast(wndProc, c_void_p).value)
    123             return cast(c_void_p(oldAddr), WNDPROC)

ArgumentError: argument 3: <class 'TypeError'>: wrong type

During handling of the above exception, another exception occurred:

ArgumentError                             Traceback (most recent call last)
D:\Anaconda\lib\site-packages\kivy\base.py in runTouchApp(widget, slave)
    503         else: 
--> 504             EventLoop.window.mainloop()
    505     finally:

D:\Anaconda\lib\site-packages\kivy\core\window\window_sdl2.py in mainloop(self)
    751  

请帮助我,为什么它不起作用? 这是工作示例:https://kivy.org/doc/stable/guide/basic.html

0 个答案:

没有答案