Are image lists possible with Sikuli?

Asked by arminius

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:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
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

Revision history for this message
RaiMan (raimund-hocke) said :
#2

I eliminated unnecessary brackets.

Revision history for this message
arminius (arminius75) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
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.