Bootstrap Chameleon Logo

Reload python when launch Chameleon Tool

The Python logic needs to take effect immediately during tool development. We could reload the python tool module in the "InitCmd" field of ChameleonTools's json file.

The modified logic will be automatically reloaded each time the tool is opened.

Take MinimalExample tool for example:

Change the InitPyCmd in MinimalExample.json

   "InitPyCmd": "import Example, importlib; importlib.reload(Example); chameleon_example = Example.MinimalExample.MinimalExample(%JsonPath)",

And add the code below in the init.py of the Package: Example

TAPython/Python/Example/init.py

from . import MinimalExample
import importlib

importlib.reload(MinimalExample)

Then when user click the menu, it will execute the " importlib.reload(Example)", then MinimalExample.py will be reloaded by the "Example" Package.

After tool development is complete, remove the "import" and "reload".

In addition, if you want to "hot reload" the logic without even reopening the tool, you can try this method