Add-on settings: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Martijn
No edit summary
 
(96 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{note|Deprecated - Addons submitted to the Kodi 19 Matrix (and up) can use the new setting format.  see [[Add-on_settings_conversion]]}}
{{mininav|[[Development]]|[[Add-on development]]}}<br />
{{see also|Python development}}
== Description ==
== Description ==


settings.xml is a XML file that contains the current configuration for the addon and should be places in the resources direcory. If your addon has
settings.xml is a XML file that contains the current configuration for the addon and should be placed in the resources direcory (my.addon.id/resources/settings.xml). If your addon has
configurable items that are set by the user, put them here. This file defines what the user sees
configurable items that are set by the user, put them here. This file defines what the user sees
when they click on Addon settings for your addon. You don't need to do any coding to utilise this functionality.
when they click on Addon settings for your addon. You don't need to do any coding to utilise this functionality.
Line 7: Line 14:


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<settings>
     <category label=”32001”>
     <category label="32001">
         <setting label="32011" type="text"  id="username" default=""/>
         <setting label="32011" type="text"  id="username" default=""/>
         <setting label="32012" type="text"  id="password" option="hidden"  enable="!eq(-1,)" default=""/>
         <setting label="32012" type="text"  id="password" option="hidden"  enable="!eq(-1,)" default=""/>
Line 17: Line 24:
         <setting id="debug" type="bool" label="32013" default="false"/>
         <setting id="debug" type="bool" label="32013" default="false"/>
     </category>
     </category>
     <category label=”32010”>
     <category label="32010">
         <setting label="32032" type="action" action="RunScript($CWD/resources/lib/viewer.py, downloadreport)"/>
         <setting label="32032" type="action" action="RunScript(my.addon.id, downloadreport)"/>
     </category></settings>
     </category>
</source>
</settings>
</syntaxhighlight>




You need to supply at least one category element.
You need to supply at least one category element.
The label attribute of both categories and settings should be the id of a language string in your language files or the one of the main XBMC language file.
The label attribute of both categories and settings should be the id of a language string in your language files or the one of the main Kodi language file.


There are some functionality not cover by this wiki page. See C++ source:
  https://github.com/xbmc/xbmc/tree/master/xbmc/addons/settings/GUIDialogAddonSettings.cpp


== Elements ==


== Different types ==
=== Separators ===
Separators are purely user-interface elements that do not allow user input and therefore have no meaningful value as a setting.


'''Setting type and additional attributes can be one in the following table:'''
==== type="sep" ====
A line separator, it adds a horizontal line that is useful to separate groups of settings.


{| class="wikitable" border="1"
Example code:
! Type !! Description !! Value attribute (value="") !! Notes
<syntaxhighlight lang="xml" enclose="div">
|-
    <setting type="sep"/>
| music ||  ||  ||
</syntaxhighlight>
|-
| video ||  ||  ||
|-
| pictures ||  ||  ||
|-
| programs ||  ||  ||
|-
| local ||  ||  ||
|-
|}


==== type="lsep" ====
A label separator, it adds a heading text that can be used to display on top of a group of settings.


'''Settings can have additional attributes:'''
Attributes:
{| class="wikitable" border="0"
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
|-
| source="" || "video", "music", "pictures", "programs", "files", "local" or blank."<br />if source is blank it will use the type for shares if it is a valid share if not a valid share it will use, both local and network drives.
|-
| visible="" || "true", "false" or conditional."<br />Determines if the setting is displayed in the settings dialog (default = 'true')"<br />You can also use a conditional statement: visible="System.HasAddon(plugin.video.youtube)"
|-
| enable="" || Allows you to determine whether this setting should be shown based on the value of another setting. 3 comparators are available:"
* eq() Equal to
* gt() Greater than
* lt() Less than
 
You can AND the comparators using the + symbol and negate it using the ! symbol (e.g. !eq() ). Each comparator takes 2 operands:
* Relative position of setting to compare
* Value to compare against
 
Thus if we place settings in our file in this order:
: myFirst setting
: mySecondSetting
: myThirdSetting
 
for the third setting we might add the option:<br />
enable="gt(-2,3) + lt(-2,10)"<br /><br />
You can also use a conditional statement: enable="System.HasAddon(plugin.video.youtube)"
|}
 
==Elements==
 
=== Line separator ===
 
Separator adds a horizontal separating line between other element


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting type="sep"/>
     <setting label="32032" type="lsep"/>
</source>
</syntaxhighlight>


=== Text input ===
Text input elements allow a user to input text in various formats. The "label" attribute must contain an id from the language file that indicates which text to display for the input field.


=== Label separator ===
==== type="text" ====
Allow a user to enter one line of text.


Separator adds a label as separator between other element
Attributes:
* '''id="''string''"''' (required) - the name of the setting.
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* option="hidden"|"urlencoded" (optional)
:if set to "hidden", each characters entered by the user will be obfuscated with an asterisks ("*"), as is usual for entering passwords.
:if set to "urlencoded", each non-alphanumeric characters entered by the user will be "escaped" using %XX encoding.
* default="''value''" (optional) - the default value.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32032" type="lsep"/>
     <setting label="32033" type="text" id="username" />
</source>
</syntaxhighlight>


The value entered by the user is saved as a string value on disk:
<syntaxhighlight lang="xml" enclose="div">
    <setting id="username" value="john.doe" />
</syntaxhighlight>
{{Note|Security consideration: when using <nowiki>option="hidden"</nowiki>, the value entered by the user is still saved as an unencrypted string value on disk.}}


==== type="ipaddress" ====
Allow a user to enter an ip address as text.


=== Text input ===
Attributes:
* '''id="''string''"''' (required) - the name of the setting.
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* default="''value''" (optional) - the default value.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32033" type="text" id="username"/>
     <setting label="32035" type="ipaddress" id="ipaddress"/>
</source>
</syntaxhighlight>


The value entered by the user is saved as a string value on disk:
<syntaxhighlight lang="xml" enclose="div">
    <setting id="ipaddress" value="127.0.0.1" />
</syntaxhighlight>


Values is saved as a float value:
<source lang="xml">
    <setting id="service" value="john.doe" />
</source>


=== Numeric input ===
Numeric input elements allow a user to enter a number. The "label" attribute must contain an id from the language file that indicates which text to display for the input field.


Attribute:
==== type="number" ====
*option="false" (This controls if text is visible or hidden as password field. Possible values are ''true'' or ''false''.)
Allows the user to enter an integer using up/down buttons.
*option="urlencoded"


=== IP address input ===
Attributes:
* '''id="''string''"''' (required) - the name of the setting.
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* default="''value''" (optional) - the default value.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32033" type="ipaddres" id="ipaddress"/>
     <setting label="32036" type="number" id="code"/>
</source>
</syntaxhighlight>


The value entered by the user is saved as a string value on disk:
<syntaxhighlight lang="xml" enclose="div">
    <setting id="code" value="127000" />
</syntaxhighlight>


Values is saved as a float value:
{{Note|In Python, calling xbmcplugin.getSetting will return the number as a string value, which must be converted to an integer value if needed}}
<source lang="xml">
    <setting id="service" value="127.0.0.1" />
</source>






=== Numeric input ===
=== Date and time  input ===
==== type="date" ====
Attributes:
* '''id="''string''"''' (required) - the name of the setting
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display or string
* default="2015-03-12" (optional) - the default value.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32033" type="num" id="code"/>
     <setting id="record_date" type="date" label="32030" default="2015-03-12"/>
</source>
</syntaxhighlight>


==== type="time" ====
Attributes:
* '''id="''string''"''' (required) - the name of the setting
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display or string
* default="13:13" (optional) - the default value.


Values is saved as a string value:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting id="service" value="127000" />
     <setting id="record_time" type="time" label="32031" default="13:13"/>
</source>
</syntaxhighlight>


=== Boolean ===
Boolean input elements allow a user to switch a setting on or off.


=== File selector ===
==== type="bool" ====
Attributes:
* '''id="''string''"''' (required) - the name of the setting
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* default="true"|"false" (optional) - the default value.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32033" type="fileenum" id="file" value="path_to_files"/>
     <setting label="32033" type="bool" id="background" default="false"/>
</source>
</syntaxhighlight>
 


Values is saved as a string value:
{{Note|"true" and "false" are case sensitive!}}
<source lang="xml">
    <setting id="file" value="sm://path_to_files/file.ext" />
</source>


The value entered by the user is saved as a string "true" or "false":
<syntaxhighlight lang="xml" enclose="div">
    <setting id="background" value="false" />
</syntaxhighlight>


=== Folder selector ===
{{Note|In Python, calling xbmcplugin.getSetting will return a string "true" or "false", which must be converted to a boolean value if needed}}


Example code:
<source lang="xml">
    <setting label="32033" type="folder" id="folder" source="auto" option="writeable"/>
</source>




Values is saved as a string value:
=== Select dialog ===
<source lang="xml">
Will open separate selection window
    <setting id="file" value="sm://path_to_files/"/>
</source>


Attributes:
==== type="select" ====
*source="auto" (auto|images|....)
* '''id="''string''"''' (required) - the name of the setting
*option="writeable" (enables folder creation button in select dialog)
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* '''values="''value1''[|''value2''[...]]" - or -
* '''lvalues="''id1''[|''id2''[...]]" (required): A list of values or language file ids from which the user can choose.
<syntaxhighlight lang="xml" enclose="div">
    <setting id="id_select" type="select" label="32000" lvalues="32001|32002|32003|32004" />
</syntaxhighlight>




==== type="addon" ====
* '''id="''string''"''' (required) - the name of the setting
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* '''addontype="''xbmc.metadata.scraper.movies''"''' (required) - type of addon.
* multiselect="''true|false''" (optional) - allows to select several addons
<syntaxhighlight lang="xml" enclose="div">
    <setting id="id_addon" type="addon" label="32111" default="" addontype="xbmc.metadata.scraper.movies"  multiselect="true" />
</syntaxhighlight>


=== Bool ===
=== Spinner ===
A rotary selector allows the user to selected from a list of predefined values.


Creates radio button with two states on/off. Set default or value attribute to ''true'' or ''false'' (note case sensitive). Using xbmcplugin.getSetting(pluginId,'setting_id_tag') on a bool will return string ''true'' or ''false''. Use appropriate conversion to turn into real boolean.
==== type="enum" or "labelenum" ====
Both element types work the same except that the "enum" type will use the index of the chosen value, wheras the "labelenum" will use the actual value.


Arguments:
* '''id="''string''"''' (required) - the name of the setting
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* '''values="''value1''[|''value2''[...]]" - or -
* '''lvalues="''id1''[|''id2''[...]]" (required):
: A list of values or language file ids from which the user can choose.
* values="$HOURS" is special case to select hour
* sort="yes" - sorts labels ( works only for type="labelenum" )


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32033" type="bool" id="background" default="false"/>
    <setting label="32018" type="enum" id="service1" lvalues="32021|32022|32023|32024"/>
</source>
    <setting label="32020" type="labelenum" id="service3" lvalues="32021|32022|32023|32024"/>
     <setting label="32022" type="enum" id="default_enumhours" values="$HOURS" />
</syntaxhighlight>


* Selecting the value "One" will return the int value "0", selecting the value "Two" will return the int value "1", etc.


Values is saved as a string value:
The value entered by the user is saved as a string. For "enum"-type settings the index of the value is saved, starting at 0 for the first value. For "labelenum"-type settings the value is saved or, in case the lvalues attribute is used, the label translated in the language of the user.
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting id="service" value="false" />
    <setting id="service1" value="0" />
</source>
     <setting id="service3" value="SomethingTranslated" />
</syntaxhighlight>






=== Selector ===
=== Slider ===
Will display a slider control
==== type="slider" ====
Allows the user to select a numberic value using a horizontal sliding bar.


Selector gives you a control from which you can selected predefined values.
Example:
Below are some possible applications.
<syntaxhighlight lang="xml" enclose="div">
    <setting label="32053" type="slider" id="limit" default="20" range="5,5,100" option="int" />
    <setting label="32053" type="slider" id="limit" default="20" range="0,100"/>
</syntaxhighlight>


==== Return string ====
Attributes:
* '''id="''string''"''' (required) - the name of the setting.
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* '''range="''min''[,''step''],''max''"''' (required) - specify the range of valid values.
* '''option="int"|"float"|"percent"''' (required) - specifies whether to allow the user to choose between integers, floating point numbers or a percentage.
* default="''value''" (optional) - the default value.


Example code:
The value entered by the user is saved as a string representation of a floating point value on disk:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32019" type="labelenum" id="service" values="One|Two|Three|Four"/>
     <setting id="limit" value="5.000000" />
</source>
</syntaxhighlight>
*Selected value "Two" will return string value "Two"


{{Note|In Python, calling xbmcplugin.getSetting will return a string, which must be converted to an int, float or percentage value if needed}}


Values is saved as a string value:
<source lang="xml">
    <setting id="service" value="Two" />
</source>




=== Browser dialog ===
File and folder browsing elements allow a user to select a file or folder by browsing the local disks or network. You can specify a media type to show only files of the chosen type to the user. The "label" attribute must contain an id from the language file that indicates which text to display for the input field.


==== Return int  ====
==== type="file", "audio", "video", "image" or "executable" ====
Allow the user to browse for and select a file. When using type="audio", "video", "image" or "executable", only files of those types are displayed to the user.


This return the int value of the selected value starting with 0
Attributes:
* '''id="''string''"''' (required) - the name of the setting
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* default="''value''" (optional) - the default value.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32019" type="enum" id="service" values="One|Two|Three|Four"/>/>
     <setting label="32033" type="file" id="file" default="path_to_files"/>
</source>
</syntaxhighlight>
*Selected value "Two" will return int value "1"
 


Values is saved as a float value:
The full path to the file selected by the user is saved as a string value on disk:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting id="service" value="1.000000" />
     <setting id="file" value="smb://path_to_files/file.ext" />
</source>
</syntaxhighlight>


==== type="folder" ====
Allow the user to browse for and select a folder.


 
* '''id="''string''"''' (required) - the name of the setting
==== Use value string id ====
* '''label="''id''"''' (required) - an id from the language file that indicates which text to display.
* source="video", "music", "pictures", "programs", "files", "local" or blank - will show the respective folders from sources.xml in the browse dialog. source="" will list both local drives and network shares.
* default="''value''" (optional, default="") - the default value.
* option="writeable" (optional, default="") - the user can be allowed to create and select new folders by setting this argument.


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
     <setting label="32019" type="labelenum" id="service" lvalues="32001|32002"/>
     <setting label="32033" type="folder" id="folder" source="auto" option="writeable"/>
</source>
</syntaxhighlight>
 
 
Values is saved as a string value:
<source lang="xml">
    <setting id="service" value="32001" />
</source>
 


The full path to the folder selected by the user is saved as a string value on disk:
<syntaxhighlight lang="xml" enclose="div">
    <setting id="folder" value="smb://path_to_files/"/>
</syntaxhighlight>


==== Use value string ====
==== type="fileenum" ====
Display files in a folder as an enum selector.


Example code:
Example: List sub-folders of the 'resources' folder for this add-on in the settings.
<source lang="xml">
    <setting label="32019" type="labelenum" id="service" values="One|Two|Three|Four"/>
</source>


<syntaxhighlight lang="xml" enclose="div">
    <setting label="32000" id="myenum" type="fileenum" values="resources" mask="/" />
</syntaxhighlight>


Values is saved as a string value:
==== Extra attributes ====
<source lang="xml">
    <setting id="service" value="Two" />
</source>


* mask="''value''" - filter selectable files. Examples: "/" - display only folders. "*.txt" - display only .txt files.
* option="hideext" - hide file extensions.




=== Slider ===
=== Action execution ===
==== type = "action" ====


With the slider you can let the user slect a value with the keyboard/mouse specified within the set ranges
Adds line to configuration windows which allow to execute action


Example code:
Example code:
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
    <setting label="32053" type="slider" id="limit" default="20" range="5,5,100" option="int" />
     <setting label="32032" type="action" action="RunScript(my.addon.id, downloadreport)"/>
     <setting label="32053" type="slider" id="limit" default="20" range="0,100"/>
</syntaxhighlight>
</source>
 


List of actions that can be used:
* [[List of built-in functions]]


Attributes:
Attributes:
*range="min,step,max"
* option="close" (close the settings dialog before executing the action)
    range="5,5,100"
*range="min,max"
    range="5,100"
*option="int" (only shows int values on the slider).




Values is saved as a float value:
== Conditions ==
<source lang="xml">
    <setting id="limit" value="5.000000" />
</source>




'''Settings can optionally have a visible and/or enable attribute:'''
{| class="prettytable" border="0"
|-
| visible="" || "true", "false" or conditional.<br />Determines if the setting is displayed in the settings dialog (default = 'true')"<br />
|-
| enable="" || "true", "false" or conditional.<br />Allows you to determine whether this setting should be shown as greyed-out and unable to be changed.
|-
| conditions || 3 comparators are available to allow a setting to be made visible or enabled based on other settings:
* eq() Equal to
* gt() Greater than
* lt() Less than


=== Execute action ===
One can AND the comparators using the + symbol, and OR the comparators using the | symbol. A combination of AND and OR is not currently supported.


Separator adds a label as separator between other element
One can negate a comparator using the ! symbol (e.g. !eq() ).


Example code:
Each comparator takes 2 operands:
<source lang="xml">
* Relative position of setting to compare
    <setting label="32032" type="action" action="RunScript($CWD/resources/lib/viewer.py, downloadreport)"/>
* Value to compare against
</source>


Thus if we place settings in our file in this order:
: myFirstSetting
: mySecondSetting
: myThirdSetting


List of actions that can be used:
for the third setting we might add the option:<br />
*[[List_of_built-in_functions]]
enable="gt(-2,3) + lt(-2,8)"<br /><br />
 
You can also use a conditional statement: enable="System.HasAddon(plugin.video.youtube)"
 
Attributes:
*option="close" (close the settings dialog before executing the action)


Comparisons CANNOT be made across category/page boundaries. If one needs to compare to a setting on a different page, a copy of the setting with the same id can be placed on the page where the comparison is to take place and then hidden by setting visible to 'false'. The value is automatically updated when the setting on the other page is updated.
|}


==Subsettings==


==See also==
You can create a subsetting by adding '''subsetting="true"''' to a setting.
* [[Add-ons]]
This will add dash in front of the setting.
* [[:Category:All add-ons]]


'''Development:'''
* [[Add-on development]]
* [[Python development]]


[[Category:Add-ons|*]]
[[Category:Add-ons|*]]
[[Category:Settings]]
[[Category:Settings]]
[[Category:How-to]]
[[Category:Add-on development]]
[[Category:Development]]
[[Category:Development]]

Latest revision as of 00:17, 18 August 2020

Note: Deprecated - Addons submitted to the Kodi 19 Matrix (and up) can use the new setting format. see Add-on_settings_conversion


Home icon grey.png   ▶ Development ▶ Add-on development ▶ Add-on settings


Description

settings.xml is a XML file that contains the current configuration for the addon and should be placed in the resources direcory (my.addon.id/resources/settings.xml). If your addon has configurable items that are set by the user, put them here. This file defines what the user sees when they click on Addon settings for your addon. You don't need to do any coding to utilise this functionality. The format for the settings file is relatively straightforward as can be seen in the following example:

Example code:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
    <category label="32001">
        <setting label="32011" type="text"   id="username" default=""/>
        <setting label="32012" type="text"   id="password" option="hidden"  enable="!eq(-1,)" default=""/>
        <setting label="32053" type="slider" id="limit" subsetting="true" default="20" range="5,5,100" option="int" />
        <setting type="sep"/>
        <setting id="debug" type="bool" label="32013" default="false"/>
    </category>
    <category label="32010">
        <setting label="32032" type="action" action="RunScript(my.addon.id, downloadreport)"/>
    </category>
</settings>


You need to supply at least one category element. The label attribute of both categories and settings should be the id of a language string in your language files or the one of the main Kodi language file.

There are some functionality not cover by this wiki page. See C++ source:

 https://github.com/xbmc/xbmc/tree/master/xbmc/addons/settings/GUIDialogAddonSettings.cpp

Elements

Separators

Separators are purely user-interface elements that do not allow user input and therefore have no meaningful value as a setting.

type="sep"

A line separator, it adds a horizontal line that is useful to separate groups of settings.

Example code:

    <setting type="sep"/>

type="lsep"

A label separator, it adds a heading text that can be used to display on top of a group of settings.

Attributes:

  • label="id" (required) - an id from the language file that indicates which text to display.

Example code:

    <setting label="32032" type="lsep"/>

Text input

Text input elements allow a user to input text in various formats. The "label" attribute must contain an id from the language file that indicates which text to display for the input field.

type="text"

Allow a user to enter one line of text.

Attributes:

  • id="string" (required) - the name of the setting.
  • label="id" (required) - an id from the language file that indicates which text to display.
  • option="hidden"|"urlencoded" (optional)
if set to "hidden", each characters entered by the user will be obfuscated with an asterisks ("*"), as is usual for entering passwords.
if set to "urlencoded", each non-alphanumeric characters entered by the user will be "escaped" using %XX encoding.
  • default="value" (optional) - the default value.

Example code:

    <setting label="32033" type="text" id="username" />

The value entered by the user is saved as a string value on disk:

    <setting id="username" value="john.doe" />

Note: Security consideration: when using option="hidden", the value entered by the user is still saved as an unencrypted string value on disk.

type="ipaddress"

Allow a user to enter an ip address as text.

Attributes:

  • id="string" (required) - the name of the setting.
  • label="id" (required) - an id from the language file that indicates which text to display.
  • default="value" (optional) - the default value.

Example code:

    <setting label="32035" type="ipaddress" id="ipaddress"/>

The value entered by the user is saved as a string value on disk:

    <setting id="ipaddress" value="127.0.0.1" />


Numeric input

Numeric input elements allow a user to enter a number. The "label" attribute must contain an id from the language file that indicates which text to display for the input field.

type="number"

Allows the user to enter an integer using up/down buttons.

Attributes:

  • id="string" (required) - the name of the setting.
  • label="id" (required) - an id from the language file that indicates which text to display.
  • default="value" (optional) - the default value.

Example code:

    <setting label="32036" type="number" id="code"/>

The value entered by the user is saved as a string value on disk:

    <setting id="code" value="127000" />

Note: In Python, calling xbmcplugin.getSetting will return the number as a string value, which must be converted to an integer value if needed


Date and time input

type="date"

Attributes:

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display or string
  • default="2015-03-12" (optional) - the default value.

Example code:

    <setting id="record_date" type="date" label="32030" default="2015-03-12"/>

type="time"

Attributes:

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display or string
  • default="13:13" (optional) - the default value.

Example code:

    <setting id="record_time" type="time" label="32031" default="13:13"/>

Boolean

Boolean input elements allow a user to switch a setting on or off.

type="bool"

Attributes:

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display.
  • default="true"|"false" (optional) - the default value.

Example code:

    <setting label="32033" type="bool" id="background" default="false"/>

Note: "true" and "false" are case sensitive!

The value entered by the user is saved as a string "true" or "false":

    <setting id="background" value="false" />

Note: In Python, calling xbmcplugin.getSetting will return a string "true" or "false", which must be converted to a boolean value if needed


Select dialog

Will open separate selection window

type="select"

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display.
  • values="value1[|value2[...]]" - or -
  • lvalues="id1[|id2[...]]" (required): A list of values or language file ids from which the user can choose.
    <setting id="id_select" type="select" label="32000" lvalues="32001|32002|32003|32004" />


type="addon"

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display.
  • addontype="xbmc.metadata.scraper.movies" (required) - type of addon.
  • multiselect="true|false" (optional) - allows to select several addons
    <setting id="id_addon" type="addon" label="32111" default="" addontype="xbmc.metadata.scraper.movies"  multiselect="true" />

Spinner

A rotary selector allows the user to selected from a list of predefined values.

type="enum" or "labelenum"

Both element types work the same except that the "enum" type will use the index of the chosen value, wheras the "labelenum" will use the actual value.

Arguments:

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display.
  • values="value1[|value2[...]]" - or -
  • lvalues="id1[|id2[...]]" (required):
A list of values or language file ids from which the user can choose.
  • values="$HOURS" is special case to select hour
  • sort="yes" - sorts labels ( works only for type="labelenum" )

Example code:

    <setting label="32018" type="enum" id="service1" lvalues="32021|32022|32023|32024"/>
    <setting label="32020" type="labelenum" id="service3" lvalues="32021|32022|32023|32024"/>
    <setting label="32022" type="enum" id="default_enumhours" values="$HOURS" />
  • Selecting the value "One" will return the int value "0", selecting the value "Two" will return the int value "1", etc.

The value entered by the user is saved as a string. For "enum"-type settings the index of the value is saved, starting at 0 for the first value. For "labelenum"-type settings the value is saved or, in case the lvalues attribute is used, the label translated in the language of the user.

    <setting id="service1" value="0" />
    <setting id="service3" value="SomethingTranslated" />


Slider

Will display a slider control

type="slider"

Allows the user to select a numberic value using a horizontal sliding bar.

Example:

    <setting label="32053" type="slider" id="limit" default="20" range="5,5,100" option="int" />
    <setting label="32053" type="slider" id="limit" default="20" range="0,100"/>

Attributes:

  • id="string" (required) - the name of the setting.
  • label="id" (required) - an id from the language file that indicates which text to display.
  • range="min[,step],max" (required) - specify the range of valid values.
  • option="int"|"float"|"percent" (required) - specifies whether to allow the user to choose between integers, floating point numbers or a percentage.
  • default="value" (optional) - the default value.

The value entered by the user is saved as a string representation of a floating point value on disk:

    <setting id="limit" value="5.000000" />

Note: In Python, calling xbmcplugin.getSetting will return a string, which must be converted to an int, float or percentage value if needed


Browser dialog

File and folder browsing elements allow a user to select a file or folder by browsing the local disks or network. You can specify a media type to show only files of the chosen type to the user. The "label" attribute must contain an id from the language file that indicates which text to display for the input field.

type="file", "audio", "video", "image" or "executable"

Allow the user to browse for and select a file. When using type="audio", "video", "image" or "executable", only files of those types are displayed to the user.

Attributes:

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display.
  • default="value" (optional) - the default value.

Example code:

    <setting label="32033" type="file" id="file" default="path_to_files"/>

The full path to the file selected by the user is saved as a string value on disk:

    <setting id="file" value="smb://path_to_files/file.ext" />

type="folder"

Allow the user to browse for and select a folder.

  • id="string" (required) - the name of the setting
  • label="id" (required) - an id from the language file that indicates which text to display.
  • source="video", "music", "pictures", "programs", "files", "local" or blank - will show the respective folders from sources.xml in the browse dialog. source="" will list both local drives and network shares.
  • default="value" (optional, default="") - the default value.
  • option="writeable" (optional, default="") - the user can be allowed to create and select new folders by setting this argument.

Example code:

    <setting label="32033" type="folder" id="folder" source="auto" option="writeable"/>

The full path to the folder selected by the user is saved as a string value on disk:

    <setting id="folder" value="smb://path_to_files/"/>

type="fileenum"

Display files in a folder as an enum selector.

Example: List sub-folders of the 'resources' folder for this add-on in the settings.

    <setting label="32000" id="myenum" type="fileenum" values="resources" mask="/" />

Extra attributes

  • mask="value" - filter selectable files. Examples: "/" - display only folders. "*.txt" - display only .txt files.
  • option="hideext" - hide file extensions.


Action execution

type = "action"

Adds line to configuration windows which allow to execute action

Example code:

    <setting label="32032" type="action" action="RunScript(my.addon.id, downloadreport)"/>

List of actions that can be used:

Attributes:

  • option="close" (close the settings dialog before executing the action)


Conditions

Settings can optionally have a visible and/or enable attribute:

visible="" "true", "false" or conditional.
Determines if the setting is displayed in the settings dialog (default = 'true')"
enable="" "true", "false" or conditional.
Allows you to determine whether this setting should be shown as greyed-out and unable to be changed.
conditions 3 comparators are available to allow a setting to be made visible or enabled based on other settings:
  • eq() Equal to
  • gt() Greater than
  • lt() Less than

One can AND the comparators using the + symbol, and OR the comparators using the | symbol. A combination of AND and OR is not currently supported.

One can negate a comparator using the ! symbol (e.g. !eq() ).

Each comparator takes 2 operands:

  • Relative position of setting to compare
  • Value to compare against

Thus if we place settings in our file in this order:

myFirstSetting
mySecondSetting
myThirdSetting

for the third setting we might add the option:
enable="gt(-2,3) + lt(-2,8)"

You can also use a conditional statement: enable="System.HasAddon(plugin.video.youtube)"

Comparisons CANNOT be made across category/page boundaries. If one needs to compare to a setting on a different page, a copy of the setting with the same id can be placed on the page where the comparison is to take place and then hidden by setting visible to 'false'. The value is automatically updated when the setting on the other page is updated.

Subsettings

You can create a subsetting by adding subsetting="true" to a setting. This will add dash in front of the setting.