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

RaiMan proposed the following answer:
# comment #4

try to put the handler inside the class:


class SeaTowTests(unittest.TestCase):

    SeaTowArea = None

    def weatherAlertHandler(self, event):
        if exists(WeatherAlertNoBtn):
             click(getLastMatch())
        else:
             print("In weatherAlertHandler")
             assert exists(WeatherAlertNoBtn)

    def setUp(self):
        print("setting things up")
        SeaTowArea = find(SeaTowSim)
        SeaTowArea.highlight(3)
        SeaTowArea.onAppear(WeatherAlert, self.weatherAlertHandler)
        SeaTowArea.observe(FOREVER, background=True) # the observe runs in a 
separate process in background
        # and script continues
        SeaTowTests.SeaTowArea = SeaTowArea # to save the region for tearDown 
in a class variable

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to