Skip to content, Skip to search

Changes

Script Parameters

14 bytes added, 6 June
Update to latest preferred parameter syntax
<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].}}
=== Multiple Choice ===
Any parameter can be turned into a multiple-choice selector by adding a <code>choices = {...}</code> property:
<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[] listOfPaths(label="select files or folders", style="both")
print("There are "+listOfPaths.length+" paths selected.");
<source lang="python">
#@ File(label="Select a file", style="file") myFile#@ File(label="Select a directory", style="directory") myDir
print(myFile)
<source lang="python">
#@ File(label="Select an image file", style="extensions:png/jpg") myImageFile
print(myImageFile)
<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
11,834
edits