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
How do I call print1 within the object?
I tried doing at XXXXXX
- self.print1()
- self.print1(self)
- print1(self)
- primt1()
- c = AlarmBox()
- c.print1()
in java you can do:
this.print1() or print1() !
Prahalad Gaggar
11.6k17 gold badges58 silver badges73 bronze badges
-
did you get an error message?Cfreak– Cfreak2013年06月14日 04:56:03 +00:00Commented Jun 14, 2013 at 4:56
3 Answers 3
You can do this in python as well, but you need to execute your code at some point:
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 is not a place to execute code, it's a place to define class members variables and methods.
answered Jun 14, 2013 at 4:56
mishik
10k9 gold badges48 silver badges69 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
At the outermost level (same indent level as class AlarmBox, you can declare code that is not part of that class:
c = AlarmBox()
c.print1()
The problem was that your code at XXXXXX was within the class.
answered Jun 14, 2013 at 4:59
Brent Washburne
13.2k4 gold badges65 silver badges86 bronze badges
Comments
Use constructor
def __init__(self):
self.print1()
Comments
lang-py