Display variable value (loop counter) on-screen during loop?

Asked by tjonnyc

Let's say I have a counter loop:

-------------------------------------
for a in range(100):
    {do something}
    {do something else}
------------------------------------

I would like to display a pop-up / window / overlay *on the screen* while the loop is running, so when I look at the remote machine I would see "NNN / 100" and know how close it is to completion.

Can anyone suggest a way this can be done?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
tjonnyc
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Not easily possible on the script level (guess you are not working on the Java level - or do you?).

There is no parallel auto-vanishing display available currently.

You would have to setup something like I am using with the yellow badges at setup and IDE startup. To be most flexible, you have to delegate this to a thread.

But you have to take into account: your running script will "see" your display too, if it is displayed asynchronously or even constantly with updated content. So you would have to take care, that it does not overlay something you need to be visible in your running script.

So to help you further come back with information on your scripting/programming skills.

Revision history for this message
tjonnyc (tjonnyc) said :
#2

There is plenty of screen space to hold a display/popup/overlay, without interfering with the web app. The app is 1000x700, and my monitor is 1920x1080 - there's a 460-pixel side margin, and about 200 pixels on the bottom.

I don't need it to be flexible or nice-looking - even a basic pop-up with plain text that says "Run # NN of 100" would be enough.

I just realized another possible approach that might be simpler:

1.) Open Google Documents in one of the tabs.
2.) After executing the 1st part of the code, while waiting for the "OK" message, switch to the Google Docs tab & paste the loop-counter value.
3.) Use another computer to look at the Google Document.

Would it be easier to paste the value of "a" in "for a in range(100)" instead of trying to display it on-screen?
If so, how would you do it?

My experience with programming is limited to understanding basic concepts, and enough logic to figure out / extrapolate things from examples. I have written about 50 functional scripts that manage passwords, play online games, and sort out files... but I'm not a "programmer" in the full sense of the word. Give me an example, and I can clone it ;)

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

So if it is possible for you, to just look at something on another computer, that is produced on the remote computer, running the script:
just create a file with a name like runningNNN.txt in a folder accessible from both computers (e.g. a share in the local net) and you have what you want.

# at beginning of script
import os
dir = "absolute path to shared folder"

# at the trigger point
fileName = os.path.join(dir, "running%s.txt"%str(counter))
f = open(fileName, "w")
f.close()

Revision history for this message
tjonnyc (tjonnyc) said :
#4

OK, that could work. But a more flexible / reliable solution would be pasting the counter value into Google Docs - since I could access it from anywhere, whether I'm on the local net or not. Is that possible?

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

ok, you might do this, but ...
... you must do that before triggering the last action in your working tab (since I guess the popup you are waiting for appears in the working tab window, which is only visible, when selected)

But if you have a possibility, to create/modifiy a file locally, that is then automatically synched to the cloud (like e.g. DropBox) this would be much easier.

Revision history for this message
tjonnyc (tjonnyc) said :
#6

Raimund, I really appreciate all the info, you're the best!

I will definitely try your solution, and post the simplified code if it works, as an example to others.