Skip to content, Skip to search

Changes

Script Parameters

30 bytes added, 06:56, 17 February 2018
By convention, use spaces before input parameters, while no spaces are allowed before script directives and ItemIO specification such as OUTPUT
<ol>
<li>Parameter declarations begin with <code>#@</code>. Each such line contains a single parameter declaration or script directive and nothing else.</li><li><code>#@type Type variableName</code> will declare an input of the indicated type, assigned to the specified name.</li><li><code>#@output type Type outputName</code> will declare the variable of the specified name as an output parameter with the given type.</li>
</ol>
<source lang="python">
#@String(label="Please enter your name") name
#@output String greeting
<source lang="python">
#@String(label="Please enter your name", description="Your name") name
#@output String greeting
<source lang="python">
#@Integer(label="An integer!",value=15) someInt
</source>
<source lang="python">
#@Integer(label="An integer!",value=15,persist=false) someInt
</source>
{{Warning | Currently, "two scripts which declare the same parameter name, even with different types, will stomp each other." See [https://github.com/scijava/scijava-common/issues/193].}}
<source lang="python">
#@String(label="What mythical monster would you like to unleash?",choices={"Kraken","Cyclops","Medusa","Fluffy bunny"}) monsterChoice
</source>
<source lang="python">
#@File(label="Select a file") myFile
print(myFile)
<source lang="python">
#@File(label="Select a directory", style="directory") myDir
print(myDir)
<source lang="python">
#@String(choices={"Option 1", "Option 2"}, style="listBox") myChoice123#@String(choices={"Option A", "Option B"}, style="radioButtonHorizontal") myChoiceABC
print(myChoice123)
Bureaucrat, emailconfirmed, incoming, administrator, uploaders
707
edits