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(self)
- 打印1(自己)
- primt1()
- c = AlarmBox()
- c.print1()
在java中你可以这样做:
this.print1() 或 print1() !
请您参考如下方法:
您也可以在 python 中执行此操作,但您需要在某个时候执行您的代码:
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
def print1_caller(self):
self.print1()
XXXXX不是执行代码的地方,它是定义类成员变量和方法的地方。
