It is possible to implement macros in which the input parameters do not have to be given when the macro is called, but interactivily while the macro is running.
The macro will ask for the parameters with a prompt in the Spock command line or opening a new window. The selection between this two ways is done in the Sardana sardanacustomsettings.py file by setting the variable INPUTHANDLER to SpockInputHandler (spock CL) or QtInputHandler (new window for entering the value). The default value is SpockInputHandler.
The following example shows the four ways of declaring a macro as interactive:
from sardana.macroserver.macro import macro, Macro, Type class ask_name_c(Macro): """Macro class to ask for user name""" interactive = True def run(self): answer = self.input("What's your name?",data_type=Type.String) self.output("So, your name is '%s'", answer)
The call to:
is the one asking for the input value. 'data_type' and 'default_value' are optional.