Script repository译: 脚本存储库
Note译: 注意
Usage: Copy-paste the code lines displayed below or the linked .py
file contents into Python console in Slicer. Or save them to a .py
file and run them using execfile
.译: **用法:将下面显示的代码行或链接的.py文件内容复制粘贴到Slicer中的Python控制台中。 或者将它们保存到.py
文件中,然后使用execfile
运行它们。
Launch Slicer译: 启动Slicer
Open a file with Slicer at the command line译: 在命令行
Open imagefile.nrrd
file in Slicer:译: 上使用Slicer打开文件在Slicer中打开imagefile.nrrd
文件:
Slicer.exe /full/path/to/imagefile.nrrd
Note译: 注意
It may be necessary to specify full path to the Slicer executable and to the file that needs to be loaded.译: 可能需要指定Slicer可执行文件的完整路径,并 到需要加载的文件。
To load a file with non-default options, you can use --python-code
option to run slicer.util.load...
commands.译: 要加载具有非默认选项的文件,可以使用–python-code选项来运行slicer.util.load …命令。
Open an .mrb file with Slicer at the command line译: 在命令行上使用Slicer打开.mrb文件
Slicer.exe --python-code "slicer.util.loadScene('f:/2013-08-23-Scene.mrb')"
Run Python commands in the Slicer environment译: 在Slicer环境中运行Python命令
Run Python commands, without showing any graphical user interface:译: 运行Python命令,但不显示任何图形用户界面:
Slicer.exe --python-code "doSomething; doSomethingElse; etc." --testing --no-splash --no-main-window
Slicer exits when the commands are completed because --testing
options is specified.译: 当命令完成后,Slicer退出 因为指定了--testing
选项。
Run a Python script file in the Slicer environment译: 在Slicer环境中运行Python脚本文件
Run a Python script (stored in script file), without showing any graphical user interface:译: 运行Python脚本(存储在脚本文件中),但不显示任何图形用户界面:
Slicer.exe --python-script "/full/path/to/myscript.py" --no-splash --no-main-window
To make Slicer exit when the script execution is completed, call sys.exit(errorCode)
(where errorCode
is set 0 for success and other value to indicate error).译: 若要在脚本执行完成后退出Slicer,请调用sys .exit(errorCode)
(其中将errorCode设置为0表示成功,其他值表示错误)。