Favorite file in interactor PythonPart¶
If the PythonPart is created as an interactor and the pyp file is read inside the interactor, the favorite file handling must be implemented in the interactor.
Saving parameter values as favorite¶
To save the parameter values in the favorite file, the function execute_save_favorite must be implemented in the interactor as follows
def execute_save_favorite(self, file_name):
""" save the favorite data """
BuildingElementListService.write_to_file(file_name, build_ele_list)
This function is called after the name of the favorite file name has been entered in the favorite file dialog.
Reading favorite parameter values¶
To read the parameter values from the favorite file, the function execute_load_favorite must be implemented in the interactor as follows
def execute_load_favorite(self, file_name):
""" load the favorite data """
BuildingElementListService.read_from_file(file_name, build_ele_list)
palette_service.update_palette(-1, True)
This function is called after the name of the favorite file name has been entered in the favorite file dialog.
Reset parameter values to initial values¶
To reset the parameter values of the PythonPart, the function reset_param_values must be implemented in the interactor as follows
def reset_param_values(self, _build_ele_list):
""" reset the parameter values """
BuildingElementListService.reset_param_values(build_ele_list)
palette_service.update_palette(-1, True)
This function is called after the click to the reset button.
Update the parameter values¶
When the PythonPart is created as an interactor and the pyp file is read outside the interactor in the PythonParts framework, saving and reading the favorite data is also executed in the framework.
In order to execute some additional functionality after reading the favorite data, the function update_after_favorite_read must be implemented. At least the update of the property palette needs to be done as follows:
def update_after_favorite_read(self):
"""
Update the data after a favorite read
"""
palette_service.update_palette(-1, True)
This function is called after the name of the favorite file name has been entered in the favorite file dialog and the data are read from the favorite file.