onAppear(): TypeError 'NoneType' object is not callable when use observe() --- second parameter must be the name of a handler function

Asked by lynn

def MyPrint(MyString):
    print "Now system is in:", MyString

reg1=Region(Screen(1))
reg1.onAppear("GeneralSettings-1.png",MyPrint("In General"))
reg1.observe(50,False)

system display [error] TypeError ( 'NoneType' object is not callable ) after running.

And if I change as reg1.observe(50,True), no such error but script seems not working correctly, MyPrint is execute even no "GeneralSettings-1.png" display

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

see https://answers.launchpad.net/sikuli/+question/261418

the
MyPrint("In General")

is executed at the time, the interpreter sees the line with onAppear() and turns this 2nd parameter into None (the return of MyPrint()).

Can you help with this problem?

Provide an answer of your own, or ask lynn for more information if necessary.

To post a message you must log in.