How to make modification of Home module work in Custom Application?

I’m developing a custom application of Slicer and successfully build the project.
The application is switched to the “Home” module by default and I’d like to make some modification in the “Home” module.
However, whatever change I had made in the Home.py file it just doesn’t work.
For example , I added a simple line

print("HomeWidget init!")

to the __init__ method of HomeWidget and rebuild this project. When the program starts up this function just won’t be called.

How to solve this problem?

A very basic suggestion, but may be the case if I understand your problem correctly. You may be trying to change the source code and expect that the change to be reflected in the build. If so, you may need to do either of the following

  1. Run the build
  2. Edit the deployed source files in [SuperbuildPath]/Slicer-build/lib/[AppName]-5.0/qt-scripted-modules. But then remember to copy those back to source otherwise you’ll lose the changes when you run a build
  3. Edit the source code in the working copy and have a script copy the .py files to the binary folder (see just above). This is what I do when I only edit Python files
2 Likes

An additional method/option for ‘run the build’: you can use cmake/ninja/make/etc to run just the targets that copy over the .py files, ex:

cd /path/to/Slicer-build
cmake --build . --target CopySlicerPythonScriptFiles
cmake --build . --target CopySlicerPythonResourceFiles
2 Likes