Flow control question: how best to wait for user input from within a loop
Fri, 01/03/2020 - 07:31 am
I've been struggling with flow control in a program I am developing. Briefly, the user needs to classify some structures in a series of images. I have a master function that gets a list of all the images in a directory and then we will process them using a loop. For each iteration, an image window and panel are shown and the user interacts with them*. What I am struggling with is how to get the loop to wait for user input.
I have tried two things:
1. using return statements to tell the loop that the user has finished. I couldn't get this to work. It seems like my functions that generate the window and panel pop on and off the stack and I can't communicate down to the original loop.
2. using a global variable (a modification of the background task example in the Help). This feels close to working. I set a running variable to 1 and test for 0 status in the loop using do-while. However, it is not possible for the user to interact with the panel is this state (spinning black and white disk).
What am I missing? Is it better to approach this another way? Any help very much appreciated!
* this part works fine and concludes with the user clicking OK in the panel which saves the classification to disk.