Skip to content

Option Types

The Option class provides factory methods for defining typed, persistent options that generate UI controls in tool and format plugin dialogs.

Common Parameters

All option factories accept these parameters:

ParameterTypeDescription
labelstrDisplay label (first positional argument)
defaultvariesDefault value
tooltipstrTooltip text
enabled_whencallableCallback returning bool — controls visibility

Option.integer()

Spin box for integer values.

count = Option.integer("Count", default=1, min=0, max=1000)
ParameterTypeDefaultDescription
defaultint0Default value
minintNoneMinimum value
maxintNoneMaximum value

Option.real()

Double spin box for floating-point values.

scale = Option.real("Scale Factor", default=1.0, min=0.001, max=1e6, decimals=4)
ParameterTypeDefaultDescription
defaultfloat0.0Default value
minfloatNoneMinimum value
maxfloatNoneMaximum value
decimalsint2Decimal places displayed

Option.boolean()

Checkbox for true/false values.

flatten = Option.boolean("Flatten hierarchy", default=False)
ParameterTypeDefaultDescription
defaultboolFalseDefault value

Option.string()

Single-line text field.

name = Option.string("Output name", default="output")
ParameterTypeDefaultDescription
defaultstr""Default value

Option.choice()

Dropdown selector.

mode = Option.choice("Mode", choices=["Fast", "Precise", "Custom"], default="Fast")
ParameterTypeDefaultDescription
choiceslist[str]requiredAvailable options
defaultstrfirst choiceDefault selection

Option.path()

File path picker with browse button.

output = Option.path("Output file", file_filter="CSV Files (*.csv)")
ParameterTypeDefaultDescription
defaultstr""Default path
file_filterstr""File type filter string

Option.color()

Color picker button.

fill = Option.color("Fill color", default="#FF0000")
ParameterTypeDefaultDescription
defaultstr"#000000"Default color (hex)

Option.cell_choice()

Dropdown populated with all cell names from the current drawing.

target = Option.cell_choice("Target cell")
ParameterTypeDefaultDescription
defaultstr""Default cell name

Option.table()

Editable grid with typed columns. See also Panel Assembly Tutorial.

entries = Option.table(
"My Table",
columns=[
TableColumn(key="name", label="Name", col_type="string"),
TableColumn(key="value", label="Value", col_type="real", decimals=3),
],
)
ParameterTypeDefaultDescription
columnslist[TableColumn]requiredColumn definitions
defaultlist[dict][]Default rows

The value is a list[dict] where each dict maps column keys to values.

TableColumn

PropertyTypeDescription
keystrDict key for this column
labelstrColumn header
col_typestrstring, integer, real, choice, cell_choice
defaultAnyDefault value for new rows
choiceslist[str]Options for choice columns
decimalsintDecimal places for real columns
min_valueint|floatMinimum for numeric columns
max_valueint|floatMaximum for numeric columns

Conditional Visibility

Use enabled_when to dynamically enable/disable options:

class MyTool(Tool):
mode = Option.choice("Mode", choices=["Simple", "Advanced"])
threshold = Option.real(
"Threshold",
default=0.5,
enabled_when=lambda self: self.mode == "Advanced",
)
iterations = Option.integer(
"Iterations",
default=10,
enabled_when=lambda self: self.mode == "Advanced",
)

When mode is “Simple”, the threshold and iterations fields are grayed out.