Can anyone give me advice on why this problem may occur and how to I can solve this?
below is my script and thank you always for your help.
toPass = ["y", "Y"]
value = input("Do you want to move on?(Y/N) : ")
print("Sorry, I didn't understand that.")
if value not in toPass:
print("Sorry, you typed wrong value.")
nrrdDir = "F:/inputTesting"
nrrdList = [file for file in os.listdir(nrrdDir) if file.endswith(r'.nrrd')]
for volFile in nrrdList:
volName = str(volFile).strip(".nrrd")
volDir = nrrdDir + "/" + volFile
print("____" + volName + " Polishing...\n")
value = moveOn()
print("If this is printed, then input worked")
Showing the user some messages on some text console in a GUI application would be highly unusual and inconvenient for users. Instead, you can quickly create a nice and convenient GUI in Qt designer. See for example this tutorial. You can put a Segment Editor widget inside your module, so your users don’t need to switch to a different module during segmentation. Having your python script in a Slicer module also takes care of selecting inputs, outputs, installation, distribution to users, updates, etc.
If you don’t need very smooth user experience just some very quick way to run a python script somewhat interactively, then you can add a button anywhere on the GUI, for example in the status bar, and continue with the processing when the user clicked the button. For example:
nextStepButton = qt.QPushButton("Finish segmentation")
# To remove the button:
About the original issue of the unexpected behavior of the console: I’ve submitted a fix for the issue, it should be integrated into the Slicer Preview Release within a few days. I would still recommend to use buttons, widgets, etc. on a module GUI to communicate with end users, instead of via messages in a text console.
This is so awesome!!
I did tried to make a button but just could not figure out how to make it work properly!
So thank you so much for providing this awesome script!!
This is way better than what I have been doing!!
And thank you for fixing the console as well!!!