← Back to team overview

sikuli-driver team mailing list archive

[Question #403670]: I give Up. Docs make this seem simple enough, but just can't get it to work.

 

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

Hi
I have progressed in my skill that I want to start reusing functions by saving them and importing into other scripts.

I followed the docs. And that made it seem simple. But I keep getting [error] NameError ( global name 'click' is not defined)

So I followed another qquestion that said I would have to add the path to sys.path. I followed the provided example for theMain and theLib. That worked. So I added that to my script and still got the same error.

But I didn't really need to do that because the scripts are in the same folder.

So here are my scripts in the same folder:

TVTimeout.sikuli
----------------------------------------------------------
print "[Info1] This will only print once"

def Restart():
    print "[Info2] This will print everytime function is called"
    click(Pattern("1477780579267.png").similar(0.90).targetOffset(190,56))
    wait(2)
    if exists(Pattern("1477780687099.png").exact()):
        click(Pattern("1477780731704.png").exact().targetOffset(-49,0))
        wait(2)
    if exists("1477780864472.png"):
        click(getLastMatch())
        wait(1)
    if exists("1477780924740.png"):
        click(Pattern("1477780924740.png").exact().targetOffset(100,0))
        wait(1)
        click(Pattern("1477781026125.png").exact().targetOffset(148,0))
        wait(10)


TestTV.sikuli
-----------------------------
TVTimeout.Restart()


After restarting IDE and running TestTV.sikuli, I get this in the message window:
------------------------------------------------------------------------------------------------------------------------
[Info1] This will only print once
[Info2] This will print everytime function is called
[error] script [ TestTV ] stopped with error in line 3
[error] NameError ( global name 'click' is not defined )
[error] --- Traceback --- error source first line: module ( function ) statement 5: TVTimeout ( Restart ) click(Pattern("1477780579267.png").similar(0.90).targetOffset(190,56))
[error] --- Traceback --- end --------------





-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.