Options¶
- class understand.Options¶
Bases:
objectAn options object
Understand graphs, reports, and other plugins support options. This class is the interface for defining and retrieving options.
Setting options¶
Methods such as draw and report accept an
optionsargument. That argument can be either a str or an options object.When an options string is used, the format of the string is “name=value”. Multiple options are seperated with a semicolon. spaces are allowed and are significant between multi-word field names, whereas, case is not significant. The valid names and values are the same as appear in that GUI. They may be abbreviated to any unique prefix of their full names. Some examples are:
“Layout=Crossing; name=Fullname;Level=AllLevels”
“Comments=On;Show Entity Name=On”
An Option object can be used instead of an option string. Retrieve an Option object for the specific graph or report being requested using
Graph.optionsandReport.optionsrespectively. Then uselistto discover existing options. Set option values with theset.Important: Note that the option string format uses the option text, not the option name, whereas the
setmethod uses the option name, not the text. Cast the option object to a string to get the option string format (showing only non-default option values).Defining options¶
Plugins use this class to define options that users can change. Find the value of an option with
lookup.In builds before 7.1 (1221) Graph plugins only support defining options with the
definemethod andReportContextandCheckContextplugins only support defining options withcheckbox,checkbox_horiz,checkbox_vert,choice,file,integer,radio_horiz,radio_vert, ortext.In builds 7.1 (1221) and later Graph plugins may use any option method because options are displayed in the graph sidebar. The
definemethod is equivalent to thechoicemethod with the text and name set to the name. However, the context menu only supportscheckbox,checkbox_horiz,checkbox_vert,choice,radio_horizandradio_vertoptions Theintegermethod can appear in the context menu when given a range (builds 1225+).Methods Summary
Create a checkbox option.
Create a horizontal group of checkbox options.
Create a vertical group of checkbox options.
Create a choice option.
Define a context menu option.
Create a file option.
Create an integer option.
Create a label.
Return a list of this Options object's option definitions.
Lookup an option value by name.
Create a horizontal radio box option.
Create a vertical radio box option.
Set an option value by name.
Create a text option.
Methods Documentation
- checkbox(name, text, default=False) None¶
Create a checkbox option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the check box
default (bool or None) – optional, the check state. False (unchecked) by default
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).
- checkbox_horiz(name, text, choices, default=[]) None¶
Create a horizontal group of checkbox options.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the check boxes
choices (list[str]) – the options to choose from
default (list[str] or None) – optional, the list of options currently checked
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221). When lookup is called, a list[str] containing the options that were checked is returned:# Create option with three checkboxes where items 2 and 3 are initally checked option.checkbox_horiz("HorizCheck","Displayed Text",["Item1","Item2","Item3"],["Item2","Item3"]) # Lookup option later option.lookup("HorizCheck") # Returns None if nothing checked, or list of checked items such as # ["Item1","Item2","Item3"]
- checkbox_vert(name, text, choices, default=[]) None¶
Create a vertical group of checkbox options.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the check boxes
choices (list[str]) – the options to choose from
default (list[str] or None) – optional, the list of options currently checked
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221). When lookup is called, a list[str] containing the options that were checked is returned:# Create option with three checkboxes where items 2 and 3 are initally checked option.checkbox_vert("VertCheck","Displayed Text",["Item1","Item2","Item3"],["Item2","Item3"]) # Lookup option later option.lookup("VertCheck") # Returns None if nothing checked, or list of checked items such as # ["Item1","Item2","Item3"]
- choice(name, text, choices, default='') None¶
Create a choice option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the choices combination box
choices (list[str]) – the options to choose from
default (str or None) – optional, the default choice
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).
- define(name, values, value='') None¶
Define a context menu option.
- Parameters:
name (str) – the option name. This appears as a graph menu option.
values (list[str]) – the possible values for the option. These appear in a submenu beneath the option name.
value (str or None) – the default value for the option.
- Return type:
None
Before 7.1 (build 1121) this method was not valid for
CheckContextorReportContextplugins. Now it is the equivalent ofchoicewith id and text both set to the name.
- file(name, text, default) None¶
Create a file option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the file entry field
default (str or None) – optional, the default file. “” if not provided
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).
- integer(name, text, default) None¶
Create an integer option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the integer entry field
default (int or None) – optional, the default value. 0 if not provided
min (int) – optional, the minimum value of the spin box. 0 if not provided
max (int) – optional, the maximum value of the spin box. 1000000 if not provided
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221). The min and max parameters were added in build 1225.
- label(name, text) None¶
Create a label.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).
- list() list[dict[str, Any]]¶
Return a list of this Options object’s option definitions.
- Returns:
one dictionary per option definition. Dictionary keys: “name” (str), “type” (str), “text” (str), and optional keys “default_value”, “choices”, “min”, and “max” when applicable.
- Return type:
list[dict[str, Any]]
- lookup(name) Any¶
Lookup an option value by name.
- Parameters:
name (str) – the option name
- Returns:
the value. The type of the value depends on the type of the option. For example, checkbox options will be True or False, integer options are int, other option types are str.
- radio_horiz(name, text, choices, default='') None¶
Create a horizontal radio box option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the radio boxes
choices (list[str]) – the options to choose from
default (str or None) – optional, the default choice
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).
- radio_vert(name, text, choices, default='') None¶
Create a vertical radio box option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the radio boxes
choices (list[str]) – the options to choose from
default (str or None) – optional, the default choice
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).
- set(name, value) None¶
Set an option value by name.
- Parameters:
name (str) – the option name
value – the new option value
- Return type:
None
Using this method from a plugin implementation outside init()/define_options() has undefined behavior. The intended use case is for
Optionsobjects retrieved from plugin catalog objects (for example,Report.options).
- text(name, text, default) None¶
Create a text option.
- Parameters:
name (str) – the internal name to use with
lookuptext (str) – the text to display next to the text entry field
default (str or None) – optional, the default text. “” if not provided
- Return type:
None
This method was not available for
Graphoptions before 7.1 (build 1221).