← Back to team overview

sikuli-driver team mailing list archive

[Question #253589]: onChange not detecting changes

 

New question #253589 on Sikuli:
https://answers.launchpad.net/sikuli/+question/253589

Raiman,

So I'm working on this tracking tool that shows on a map (like a googlemaps satellite view) where there was movement.  It does this by showing these little red stars where the movement was detected.  The little stars are about 40-50 pixels large.   What I wanted to do is keep a log of the position the stars come up on the screen.  So I coded up a section below and it runs the code, but I never detect these stars showing up although I can clearly see them when I run the program.  I've read through several other posts on using the onChange function and thought I had it correct, but I must be doing something wrong.  Can you please take a look?  I've only included what is applicable here.  This is obviously within a class and there's other classes involved.  The self.resfile is just a file_io class that has functions for reading and writing to a result text file.   I know for sure it's entering my watch_for_tracks method and it's clicking on the start_tracking_icon, and then waiting the full 45 seconds for something to appear, but my "changed" method never gets called.  I know that because nothing gets written to my file.  But I did write a line before I called watch_for_tracks and that works so I know my file_io works (I use it for several other working programs too).

Or is there a better way altogether to do this?  

    def changed(event):
        self.resfile.write_string("Change observed\n")
        for ch in event.changes:
            center_loc = ch.getCenter()
            self.resfile.write_string("Observed track at " + str(center_loc.x) +
                                      ", " + str(center_loc.y) + "\n")

            
    def watch_for_tracks(self, tracking_icon):

        start_tracking_icon = self.toolbar_reg.exists(tracking_icon)
        if (start_tracking_icon):
            click(start_tracking_icon)
            self.watch_region.highlight(1)
            self.watch_region.onChange(25, self.changed)
            self.watch_region.observe(background=True)

            wait(45)
            self.watch_region.stopObserver()
            click(start_tracking_icon)
        else:
            self.resfile.write_string("Was not able to see the enable tracking icon \n")
            self.breakscript(None)


    def breakscript(self, event):
        exit(1)


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