简体   繁体   中英

Attribute Error Kivy

I 'm not sure why I am getting an attribute error in the following code when I try to access the instance's attribute score:

class EllipseMaker(Widget):
    score = 10


class Modules(GridLayout):
    moduleone = ObjectProperty(None)
    def on_touch_down(self,touch):
        print self.moduleone.score

In my .kv doc:

<Modules>:
    cols:1
    moduleone: ellipseone
    EllipseMaker:
        id: ellipseone
        size: (root.width/4,root.height/4)
        pos: self.parent.center

<EllipseMaker>:
   canvas:
       Ellipse:
           pos:self.pos
           size:self.size

The error I am getting is "AttributeError: 'EllipseMaker' object has no attribute 'score'"

问题是我还有一个已经定义了EllipseMaker的.kv文件,因此程序继续引用该EllipseMaker类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM