Then, it crashes with the following error message… It seems like the script cannot handle .png file properly…
creating G:/Libs/slicer/My_Module/My_Module\My_Module.png
Traceback (most recent call last):
File "g:\Libs\slicer\Slicer\Utilities\Scripts\ModuleWizard.py", line 121, in <module>
main(sys.argv[1:])
File "g:\Libs\slicer\Slicer\Utilities\Scripts\ModuleWizard.py", line 115, in main
copyAndReplace(file, template, target, templateKey, moduleName)
File "g:\Libs\slicer\Slicer\Utilities\Scripts\ModuleWizard.py", line 38, in copyAndReplace
contents = fp.read()
File "C:\Python36\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 154: character maps to <undefined>
It may be that the ModuleWizard script only works with python 2.7 (looks like you are using 3.6). Maybe try that and let us know?
Also the ExtensionWizard is probably a better way now. If you look at this “Developing and Contributing Extensions for 3D Slicer” tutorial you can see how it works. The only difference is that you pick ‘cli’ instead of ‘scripted’ when adding the module to your extension.
Yes, I was using the HelloCLI tutorial of the link.
Just now, I removed python36 and installed python27. The ModuleWizard
script finished without any error, but the png file got corrupted and I
could not open it. I assume…, not 100% sure… me, a python newbie… it
is because the file was open as text file, modified, and saved as text
file… If my assumption is right…, I guess the same is true for all
other binary files (the image files in the Data sub-folder).
Thanks for the link regarding ExtentionWizard. I’ll try it.