Parameter system

From SweepMe! Wiki
(Redirected from Placeholder)
Jump to navigation Jump to search

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:

  1. The content is exactly a known parameter. For example, using {Y} in a text edit will lead to insertion of the current year.
  2. 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.