简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM