class AlarmBox(Widget):


    hour = ["12","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]
    tensMin = ["0", "1", "2", "3", "4", "5"]
    onesMin = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    day = ["AM", "PM"]
    txt_inpt = ObjectProperty(None)


    def print1(self):
        self.txt_inpt.text("HI")

    XXXXXXX


如何在对象内调用print1?

我尝试在XXXXXX做


self.print1()
self.print1(自我)
print1(个体)
primt1()
c = AlarmBox()
c.print1()


在Java中,您可以执行以下操作:

this.print1()或print1()!

最佳答案

在最外层(与class AlarmBox相同的缩进层),您可以声明不属于该类的代码:

c = AlarmBox()
c.print1()


问题是您在XXXXXX处的代码在该类之内。

关于python - Python方法调用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17101316/

10-11 07:46