无法从cython模块导入类

时间:2018-05-24 21:47:30

标签: python kivy cython

我正在尝试按照PongBall

上的kivy教程

,但VScode在行中给出了错误

from kivy.properties import NumericProperty, ReferenceListProperty

带有消息:

  

[pylint] E0611:模块'kivy.properties'中没有名称'NumericProperty'

     

[pylint] E0611:模块'kivy.properties'中没有名称'ReferenceListProperty'

这个模块我相信cython模块,当我打开文件properties.pxd时 我可以找到以下代码:

...
cdef class NumericProperty(Property):
    cdef float parse_str(self, EventDispatcher obj, value)
    cdef float parse_list(self, EventDispatcher obj, value, ext)
...
cdef class ReferenceListProperty(Property):
    cdef list properties
    cpdef trigger_change(self, EventDispatcher obj, value)
    cpdef setitem(self, EventDispatcher obj, key, value)
...

附录: 这是我到目前为止的整个代码:

import kivy
kivy.require('1.10.0')

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty, ReferenceListProperty
from kivy.vector import Vector

class PongGame(Widget):
    pass

class PongBall(Widget):
    # velocity of the ball on x and y axis
    velocity_x = NumericProperty(0)
    velocity_y = NumericProperty(0)

    velocity = ReferenceListProperty(velocity_x, velocity_y)

    def move(self):
        self.pos = Vector(*self.velocity) + self.pos
class PongApp(App):
    def build(self):
        return PongGame()


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

问题: 为什么它不想导入,我该怎么做才能修复它?

0 个答案:

没有答案