Parameter system: Difference between revisions
No edit summary |
|||
Line 16: | Line 16: | ||
== ParameterManager == | == ParameterManager == | ||
The ParameterManager is a library that comes with SweepMe! | The ParameterManager is a library that comes with SweepMe! and can be used to query individual parameters in your script, e.g. a [[CustomFunction]] script. | ||
Here is an example how to use it: | Here is an example how to use it: |
Latest revision as of 17:22, 3 November 2023
Starting from SweepMe! version 1.5.5., a parameter system is introduced that allows you to use placeholder strings at many places in the program to make thing more variables.
A list of all defined parameters can be found using the widget Parameters.
Every parameter is a string. To enter such a parameter in a text edit field, curly brackets {...} are used. Whenever SweepMe! detects curly brackets, the content of the brackets will be replaced. There are two scenarios:
- The content is exactly a known parameter. For example, using {Y} in a text edit will lead to insertion of the current year.
- If the content is not a known parameter, SweepMe! will try to do an inline python evaluation, e.g. {2+2} will lead to insertion of 4.
You can combine the replacement of parameters and the inline python evaluation by using multiple curly brackets, e.g. {int({Y}) + int({m})} which will result in adding the integer of the current year with the integer of the current month.
Creation of individual parameters
Individual parameters can be defined using the add-on module 'Form' that is used to create formular like widgets.
ParameterManager
The ParameterManager is a library that comes with SweepMe! and can be used to query individual parameters in your script, e.g. a CustomFunction script.
Here is an example how to use it:
import ParameterManager
ParM = ParameterManager.ParameterManager()
key = "Time_elapsed_s"
value = ParM.get_parameter(key)
print("Elapsed time:", value)
The key can be any key as listed in the Parameters widget.