Automatically reload python logic every time it starts¶
During the development of the tools, you need the modified python logic to take effect immediately. You can reload the corresponding Python tool module in the InitCmd of the interface json file so that the modified tool logic is automatically reloaded each time the tool is opened.
"InitPyCmd": "import importlib, your_tools_module; importlib.reload(your_tools_module); your_tool_inst = your_tools_module.Tool(%jsonPath)"
Once the tool development is complete, remove the corresponding reload statement.
In addition, if you want to "hot reload" the corresponding logic without reopening the interface, you can use this method
Reload Python logic through buttons or menus¶
If you split the tool's logic code from the code that controls the interface, you can hot reload the corresponding logic without closing the interface. This method is suitable for relatively independent functions and modules.
Of course, it is also a convenient choice to add a temporary button in the development tool to reload the corresponding logic module:
{
"SButton": {
"Text": "Reload",
"HAlign": "Center",
"VAlign": "Center",
"OnClick": "import your_utils, importlib; importlib.reload(your_utils)"
}
},
For code involving interface logic, you can update the logic when reopening the interface throughquickly updating python logic