However, this message blocks any manual interaction until an 'OK' is given and the saving is starting, i.e. too late for a corrective measure if the Id has not been given beforehand. Any idea how this could be handled?
I'm testing this using your svImageSeq function from your script saving an image sequence does not work correctly forum post. Thus far, I'm seeing the same results that you are. Before digging into this too far, can you clarify something for me?
Are you looking to pop up a warning that would allow the user to set the display ID mid-script and then continue on?
Or are you trying to give a user a way to exit out of the script before going to the writeImageAtIndex portion if they forgot to enter display ID?
That said, I'd recommend throwing an exception rather than showing the dialog. It allows you to write code to "catch" if/when svImageSeq fails, and the JOptionPane may not work as expected if you are running your script in the background.
Yet another thing to try...if you have a reference to the layer (like "imLayer = imDisplay.getLayer(1)"), you could set the layer's ID to "thisColourBar" yourself. The only concern is dealing with the situation when someone has specified their own layer ID prior to running the script. I had to implement something very similar to this for McV's captureImage (and its "islformatters")--I'd be happy to describe it if you think it might help.
Here's another alternative method I came up with. This pops up a dialog box asking if the layer ID has been set. If 'Yes' is chosen, the script runs. If 'No' is chosen, the script terminates and tells the user to specify a layer ID before running the script again.
# If switch=3, ask user if layer ID has been set. If yes, continue. If no, terminate script. if switch == 3: idSet = JOptionPane.showConfirmDialog(None,"Did you define the layer ID?","Layer ID Defined",JOptionPane.YES_NO_OPTION) if idSet == 0: print 'Script will continue.' else: sys.exit('Script terminating. Set layer ID and run script again.')
I added this to the beginning of the svImageSeq function. I didn't change anything else in the script, so this assumes that the layer ID (if set) is set to 'thisColourBar'.