2
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

  1. self.print1()
  2. self.print1(self)
  3. print1(self)
  4. primt1()
  5. c = AlarmBox()
  6. c.print1()

in java you can do:

this.print1() or print1() !

Prahalad Gaggar
11.6k17 gold badges58 silver badges73 bronze badges
asked Jun 14, 2013 at 4:52
1
  • did you get an error message? Commented Jun 14, 2013 at 4:56

3 Answers 3

2

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

-1

Use constructor

def __init__(self):
 self.print1()
answered Jun 14, 2013 at 5:20

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.