Are image lists possible with Sikuli?

Asked by arminius on 2018-09-13

input
  images = {1: ("1536849826828.png"), 2: ("1536849837900.png")}
  first_image = (player[2])
  print(first_image)
  if exists(first_image):
    print("SAW IT")

output
  1536849837900.png
  [error] Image: Image not valid, but TextSearch is switched off!
  [error] RunTimeIDE: Exists: Abort: Jython: at test (4)
  [error] RunTimeIDE: ImageMissing: 1536849837900.png
  [error] script [ test ] stopped with error at line --unknown--

Is it possible to have a library of images in a list I can draw from, or am I just doing it wrong?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-09-13
Last query:
2018-09-13
Last reply:
2018-09-13
Best RaiMan (raimund-hocke) said : #1

This is how you can do that

--- yours is the dictionary (key/value store) variant:
player = {1: "1536849826828.png", 2: "1536849837900.png"}
# the keys can be whatever you like
first_image = player[2]
print first_image
if exists(first_image):
  print("SAW IT")

--- this would be the list variant
player = ["1536849826828.png", "1536849837900.png"]
# index starts with 0
first_image = player[1]
print first_image
if exists(first_image):
  print("SAW IT")

hope it helps

RaiMan (raimund-hocke) said : #2

I eliminated unnecessary brackets.

arminius (arminius75) said : #3

Thanks RaiMan, that solved my question.

arminius (arminius75) said : #4

How embarrassing, I changed the first lines player to images
neglected the second line, I promise that wasn't my error, I'm not completely incompetent.