Form refresh
In order to aid rapid iterations during development, the Refresh button has been introduced. Clicking the Refresh button performs all the actions associated with closing the window and opening a new one, except for closing the actual window. Modules are reloaded before re-initializing the form.
The Refresh button is aimed at developers and can be enabled when running locally. There is no equivalent for the deployed application that runs in a web browser.
Python
In Python the refresh button can be enabled by giving the show_refresh
named argument to Uiformio
:
Uiformio("namespace.app", show_refresh=True)
In order to detect the changes that were made to the app module file after starting Uiformio, importlib.reload
is used to reload a number of modules.
- Reload the module with the namespace (first input argument of Uiformio).
- Find the folder of that module and reload all modules found there (or in its subfolders).
- Call the
gui_refresh
function of the web app module, if it is implemented.
The gui_refresh
method is intended for reloading additional modules only. Example:
def gui_refresh():
importlib.reload(sys.modules["core.algorithm"])
importlib.reload(sys.modules["shared.components"])
Matlab
In Matlab the refresh button can be enabled by giving the ShowRefresh
named argument to Uiformio
:
Uiformio("namespace.app", ShowRefresh=true);
In order to detect the changes that were made to the app module file after starting Uiformio, rehash
is used to compare the timestamps for loaded functions against their timestamps on disk, and it clears loaded functions if the files on disk are newer.
Since rehash
applies to all known files and classes for folders on the search path that are not in matlabroot, there is no Matlab equivalent of gui_refresh
.