简体   繁体   English

Python和Sikuli-从列表中选择(多个)

[英]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. 如果没有任何列表项,它将执行click("go.png")并继续。 If there are any list items there, it clicks it and then executes the click("go.png") 如果那里有任何列表项,则单击它,然后执行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. 这样, click("start.png")click("go.png")起作用了。 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. 这应该按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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