How to organise my images for reuse in more than one script

Asked by David Scheele

Hi there,

this is more of a suggestion, and a medium to minor at that, but could you add the functionality to use view methods other than Details and List when searching for a picture via "Add Picture" in the SikuliX IDE?

Maybe this already exists but I can't find it.

Thanks in advance :)

Best,
David

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
RaiMan (raimund-hocke) said :
#1

If you are talking with me (RaiMan the developer):

I do not understand, what you mean.

Revision history for this message
David Scheele (david-scheele2) said :
#2

Yes, I'm talking to you ;)

In the SikuliX IDE:

http://puu.sh/h7bRi/8b693b63ef.png

will open the image loader:

http://puu.sh/h7bRF/386b6611ae.png

We see all the images, but they are not expanded so i only see the names.
Usually I can just set the visuals to use bigger tiles, actually displaying the images. But it won't work in this window:

http://puu.sh/h7bRX/0080d87360.png

I would really like that simple option

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

ok, understood ...
... but not agreed ;-)

--- I would really like that simple option
Not that simple as you might think.
Internally we use the standard Java Swing FileChooser to be system independent (one of the basic principles with SikuliX).
This feature down at the system level uses the the system specific file dialog. You might specify a file type filter and wether the dialog is for open or for save.
I just looked into the Java docs: There is no option, that allows to specify HOW the file dialog should look like.

Since for version 2 the image management will be improved, I put on the list to have an option for a group of images showing a thumbnail-like representation.

--- will open the image loader
I understand the following about what you are doing:
- you have some "image-library" as a .sikuli container
- seems all to be IDE generated screenshots with timestamp (hence anonymous) names
- for some script you are editing, you want to copy some of these library images into the current script

If I am right, then in the first place this violates the DRY (don't repeat yourself) principle of software and data structure design.
The image files should not be copied (repeated), but referenced.
To make file referencing comfortable one needs a file name concept.
In the consequence your library image files should have speaking names and should be grouped somehow.

grouping by subfolder:

.../buttons
   ok.png
   cancel.png
   ...
.../menus
   open.png
   ...

grouping be name prefix

btnOk.png
btnCancel.png
menuOpen.png

This is supported in the IDE by setting the naming Preference to manually:
after having captured, you enter the name for the image

Since currently the first structure concept is not yet directly supported, the first choice is the second concept.

In Python scripting based on import even another option is supported:
you capture with timestamp and assign a variable with a speaking name:
btnOk = "1234567890.png"

and say
from imageLib import * # imageless.sikuli is added to the image path automatically
click(btnOk)

this is sufficient for scripting, but lacks overview at the filesystem level.

the general file naming and grouping concepts are supported by addImagePath():

-- subfolders
addImagePath(<folder containing the image subfolders>)
click("buttons/ok.png")

- prefixed names
addImagePath(<folder containing the images>)
click(btnOk)

Revision history for this message
David Scheele (david-scheele2) said :
#4

Thanks for the long reply :)

Ok I see your point why this can't be implemented.

Yes, I'm actually already using manual naming of the screenshots, but I found the option only recently and a big part of my stuff just has the timestamp naming because I couldn't get around renaming them yet.

My structure now is naming them by overbearing menu names:
MainMenu.OptionMenu.OKButton.png

Wich works fine.

The thumbnails were just and idea and I though people might also find it neat ;)

Thanks again, marking as solved!

Revision history for this message
David Scheele (david-scheele2) said :
#5

Thanks RaiMan, that solved my question.

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

--- MainMenu.OptionMenu.OKButton.png

I pray to the God Of BitsAndBytes, that these dotted filenames work in all cases ;-)

Image file name handling in SikuliX is still not consistent all over the place.

The still valid recommendation:
- only use ASCII-letters and digits (no UTF-8 characters)
- should not contain spaces
- should not contain any special characters besides - (hyphen) and (underscore)

so my choice in this case would have been:
MainMenu_OptionMenu_OKButton.png

... and the main category first:
MenuMain_MenuOption_ButtonOK.png

I write this mainly for other readers of this post.