Dave
Dave

Reputation: 1071

Python and Sikuli - Selecting from a list (multiple)

Asking around a different way of doing this.

I am trying to look at the screen, decide if an image exists (from a list) and choose any that are there, then click "go". If none of the list items are there, it would execute click("go.png") and carry on. If there are any list items there, it clicks it and then executes the click("go.png")

wait("start.png", 10)
click("start.png")

class gameOne():
    def pickone():
        imageFile = ["one.png", "two.png", "three.png"]
        if exists(imageFile):
            click(imageFile)
click("go.png")

With this, the click("start.png") and click("go.png") work. It seems to just skips the class. No error is given.

Upvotes: 0

Views: 1900

Answers (1)

mbdavis
mbdavis

Reputation: 4010

You aren't using the class correctly, I'm not sure how you are expecting this to work, but you don't need that for what you're doing:

wait("start.png", 10)
click("start.png")    

imageFile = ["one.png", "two.png", "three.png"]

if exists(imageFile):
    click(imageFile)

click("go.png")

This should work as intended.

Upvotes: 1

Related Questions