我正在尝试编写代码,以便它在Image J中重复一系列命令,直到用户对结果感到满意为止。这就是我试过的:
from ij.gui import NonBlockingGenericDialog
num = True
while num is True:
#a series of a commands will go here
dia2 = NonBlockingGenericDialog("Better")
dia2.addMessage("does that look good?")
dia2.showDialog()
if dia2.wasCanceled:
rm.reset()
num = True
print num
elif dia2.wasOKed:
print "background good"
num = False
break
问题是即使对话框已经OK,脚本也会保持循环,从而创建一个无限循环。我不确定如何格式化它以在必要时正确地打破循环。