← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #170439]: Question about onAppear.

 

Question #170439 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/170439

    Status: Answered => Open

Scott Ovelmen is still having a problem:
Thank you for the information. I really appreciate the help. I am still
having issues. I was wrong about my initial comments. Both pieces of
code did not work correctly. I thought the piece below worked but when I
stuck the “try” in I found otherwise. What I am doing is moving a button
type deal in one region which produces a grey shaded area in another
region. When I run the code below, the loop stops at the correct time
(when image appears). The problem is the onAppear exit function is never
called. The code throws an exception on the highlighted line. I have
double checked the function name and have tried it with a function not
defined in a class. The exception says:

WindowUR_CT.observe(.5, background=False)
File "/home/sovelmen/Sikuli-X-1.0rc2-linux/Sikuli-IDE/sikuli-script.jar/Lib/sikuli/Region.py", line 255, in observe
File "/home/sovelmen/Sikuli-X-1.0rc2-linux/Sikuli-IDE/sikuli-script.jar/Lib/sikuli/Region.py", line 223, in targetAppeared
TypeError: releaseButton() takes exactly 1 argument (2 given) 

For reference, the release button code is:
   def releaseButton(self):
       mouseUp()
       self.done = 1     
       print 'in release'

WindowUR_CT.onAppear( image, test.releaseButton)
try:     
   for x in range(30):
      WindowUR_CT.observe(.5, background=False) (exception on this line)
      test.movePoint(-1, 0)
       if test.done == 1:
          print 'done if'
          break
       WindowUR_CT.stopObserver()   
   if x == 49:
      print 'in here'
      mouseUp()               
except:
   WindowUR_CT.stopObserver()
   mouseUp() 
   print 'except'

When I tried it the way you suggested (below), the image is not
recognized and the loop ends. Do you see where the problem is?

WindowUR_CT.onAppear(image , test.releaseButton)
WindowUR_CT.observe(FOREVER, background=True)
try:     
   for x in range(30):
       test.movePoint(-1, 0)
       if test.done == 1:
          print 'done if'
          break  
   if x == 29:
      print 'in here'
      mouseUp()               
   WindowUR_CT.stopObserver() 
except:
   WindowUR_CT.stopObserver()
   mouseUp() 
   print 'except'

Again, thank you for any help you can give.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.