Difference between revisions of "Extensions: INX widgets and parameters"
m (→Common attributes: alphabetical order) |
m (→Available types: alphabetical order) |
||
Line 53: | Line 53: | ||
|- | |- | ||
! | ! color | ||
|Creates a | |Creates a control to select a '''color value'''. | ||
The '''returned value''' is an RGBA-value. | |||
<pre> | <pre> | ||
<param name="name" type=" | <param name="name" type="color"></param> | ||
</pre> | </pre> | ||
|[[File:INX_sample-color.png]] | |||
|[[File:INX_sample- | |||
|- | |- | ||
! | ! description | ||
|Creates a | |Creates a text element. Specifying the attribute <code>xml:space="preserve"</code> preserves whitespace in the text content of the description and enables multiline text. | ||
<pre> | <pre> | ||
<param name="name" type=" | <param name="name" type="description">Some text here.</param> | ||
</pre> | </pre> | ||
When additionally setting the attribute <code>appearance="header"</code> the text is styled as a heading and can be used as another possibility to group parameters. | |||
<pre><param name="name" type="description" appearance="header">Header</param></pre> | |||
All <code>description</code> type parameters are purely informational (they do not return any value). They are intended to be used to provide additional information / help on other parameters (Consider using the <code>gui-description</code> attribute for short help texts that are specific to a single parameter, though). | |||
|[[File:INX_sample-description.png]]<br><small>default appearance</small><br><br><br><br> | |||
[[File:INX_sample-description_header.png]]<br><small>with <code>appearance="header"</code></small><br><br><br> | |||
| | |||
|- | |- | ||
Line 99: | Line 94: | ||
|- | |- | ||
! | ! float | ||
|Creates a | |Creates a textbox input to enter a '''floating point number'''. Limit the input range with the <code>min</code> and <code>max</code> attributes; set the number of decimal places with the <code>precision</code> attribute. (Default: <code>min="0"</code>, <code>max="10"</code> and <code>precision="1"</code>) | ||
<pre> | <pre> | ||
<param name="name" type=" | <param name="name" type="float" precision="3" min="0" max="9999" | ||
gui-text="Some label text"> | gui-text="Some label text">1.234</param> | ||
</param> | |||
</pre> | </pre> | ||
Use the attribute <code>appearance="full"</code> to create a slider with which the floating point value can be adjusted dynamically over the full range. | |||
|[[File:INX_sample-float.png]]<br><br>[[File:INX_sample-float_full.png|240px]] | |||
|[[File:INX_sample- | |||
|- | |- | ||
! | ! int | ||
|Creates a | |Creates a textbox input to enter an '''integer number'''. Limit the input range with the <code>min</code> and <code>max</code> attributes. (Default: <code>min="0"</code> and <code>max="10"</code>) | ||
<pre> | <pre> | ||
<param name="name" type=" | <param name="name" type="int" min="1" max="100" gui-text="Some label text">1</param> | ||
</pre> | </pre> | ||
|[[File:INX_sample- | |||
Use the attribute <code>appearance="full"</code> to create a slider with which the integer value can be adjusted dynamically over the full range. | |||
|[[File:INX_sample-int.png]]<br><br>[[File:INX_sample-int_full.png|240px]] | |||
|- | |- | ||
Line 143: | Line 134: | ||
|- | |- | ||
! | ! optiongroup | ||
|Creates a | |Creates a set of radio buttons from which '''one predefined value''' can be chosen. The different choices are created with <code><option></code> elements. The first <code><option></code> is selected by default. | ||
The '''returned value''' for <code>optiongroup</code> type parameters is the value of the <code>value</code> attribute of the selected <code><option></code>. | |||
<pre> | <pre> | ||
<param name="name" type=" | <param name="name" type="optiongroup" | ||
gui-text="Some label text"> | |||
<option value="1">First option</option> | |||
<option value="2">Second option</option> | |||
</param> | |||
</pre> | </pre> | ||
Set the attribute <code>appearance="minimal"</code> to display a drop-down list instead of radio buttons.<br> | |||
< | <small>''The option group will occupy the minimum space on the right hand side of the dialog. Versus the Enum, which expands to fill available space.''</small> | ||
|[[File:INX_sample-optiongroup.png]]<br><br><br><br><br>[[File:INX_sample-optiongroup-minimal.png]] | |||
|- | |||
! string | |||
|Creates a textbox input to enter a '''character string'''. Limit the number of characters the user is allowed to enter with the <code>max_length</code> attribute. (Default: no limit) | |||
<pre> | |||
<param name="name" type="string" gui-text="Some text label">Some default text</param> | |||
</pre> | |||
|[[File:INX_sample-string.png]] | |||
} | |||
== Localization of parameters == | == Localization of parameters == |
Revision as of 03:30, 12 February 2017
Here you will find the different parameter elements you may use in your .inx files (Inkscape Extensions)
Introduction
Use parameter elements to capture user input for further use by a script. The basic structure of the element is:
<param name="some_name" type="some_type">default value</param>
The default value is the value that is shown in the input control the first time the user opens the dialog window. Inkscape automatically displays the values used last time when the dialog window is opened again.
Common attributes
gui-description
Tooltip of the parameter, which is shown when the user hovers the mouse cursor over the active area of the parameter in question.
To enable translations for this string use the underscore variant (_gui-description
, see localization of parameters below for details).
If the value is set to true
the parameter is hidden from the GUI (default to false).
gui-text
Label of the parameter.
To enable translations for this string use the underscore variant (_gui-text
, see localization of parameters below for details).
indent
Sets indentation level of the parameter (e.g. indent="1").
name
The value of the name
attribute is used as an identifier of the parameter. It has to be unique since the value of this attribute is used to save and transmit parameter values internally!
type
The type
attribute determines the type of the parameter (possible values are boolean, int, float, string, enum, optiongroup, color, notebook, description
), see the extensive description of available types below.