Kodi Community Forum

Full Version: New settings format for addons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Hello, I want to add to my new addon a list of country selection. For this I have this:

xml:
<setting id="region_code" type="string" label="30035" help="">
    <level>0</level>
    <default>ES</default>
    <constraints>
        <options>
            <option label="30200">DZ</option>
            <option label="30201">AR</option>
            <option label="30202">AU</option>
            <option label="30203">AT</option>
            <option label="30204">AZ</option>
            <option label="30205">BH</option>
            <option label="30206">BD</option>
            ...
            <option label="30303">VE</option>
            <option label="30304">VN</option>
            <option label="30305">YE</option>
            <option label="30306">ZW</option>
        </options>
    </constraints>
    <control type="list" format="string">
        <heading>"30035"</heading>
    </control>
</setting>

Where the label in <options> is the local translation of the country name.
The question is: Can I somehow sort the options in that list according to the labels, so that the names of the countries translated in the interface language appear in alphabetical order?
nope, not possible as far as i know.
Damn... What a pitty! Thanks anyway
Is this a bug or not... not seeing the value assigned to action types/buttons - they are just blank whereas in the previous settings format, the values would display in the GUI (to the right of the actions label).
@SEIKT there are two types of action settings, one that does display a value and one that doesn't.
see the wiki examples: https://kodi.wiki/view/Add-on_settings_c...2action.22

you want to use this format:
xml:

<setting id="test34" type="string" label="32034" help="">
    <level>0</level>
    <default/>
    <constraints>
        <allowempty>true</allowempty>
    </constraints>
    <control type="button" format="action">
        <data>RunScript(weather.yahoo,Location1)</data>
    </control>
</setting>
Thanks Ron, worked like a charm.
It is possible to add a dependency if a value of another setting is empty? eg.

xml:
<dependencies>
    <dependency type="enable">
        <condition operator="!isempty" setting="apikey" />
    </dependency>
</dependencies>
yes, should be possible. see the section on using conditions in the wiki: https://kodi.wiki/view/Add-on_settings_c...Conditions

empty:
xml:

<dependencies>
     <dependency type="enable" operator="is" setting="othersetting"></dependency>
</dependencies>

not empty:
xml:

<dependencies>
    <dependency type="enable" operator="!is" setting="othersetting"></dependency>
</dependencies>
Sorry, but this doesn't work. The setting is always disabled independend from operator "!is" or "is" and my IDE (PyCharm) notes this syntax as not conform to xml (xml tag has empty body). Even 
xml:
<dependency type="enable" operator="!is" setting="othersetting"/>
has the same result.
@_BJ1  i've tested it with these settings, which work ok:
xml:

<setting id="apikey" type="string" label="611" help="">
    <level>0</level>
    <default></default>
    <constraints>
        <allowempty>true</allowempty>
    </constraints>
    <control type="edit" format="string">
        <heading>987</heading>
    </control>
</setting>

<setting id="download" type="boolean" label="33003" help="">
    <level>0</level>
    <default>true</default>
    <dependencies>
        <dependency type="enable" operator="!is" setting="apikey"></dependency>
    </dependencies>
    <control type="toggle"/>
</setting>

in case you can't get it to work, please post your settings.
Yes, it works indeed. Was a stupid typo...
Thanks for this, just ran it and it worked well.

One thing I noticed was that if a language string was empty (like in my old settings) but with new settings kodi crashed as soon as I brought up the content menu on the source.

I fixed it by removing the missing language string

php:
<setting label="30105" type="select" values="de|en|es|fr|he||hu|it|ja|nl|no|pl|pt|ru|sv|zh" id="language" default="en"/>
php:
<option>he</option>
</option> (removed)
<option>hu</option>

Works nicely now.
I'm wondering how to set a default value from strings.po?

xml:
<setting id="lg_protocol" type="string" label="30012" help="">
<level>0</level>
<default>30017</default>
<constraints>
<allowempty>true</allowempty>
</constraints>
<control type="edit" format="string">
<heading>30017</heading>
</control>
</setting>

That displays the value "30017" but not the label entry #30017  from strings.po
Hi All
Need some advise with the below after converting the settings.xml with the add-on

Quote:<setting label="32007" type="action" option="close" action="RunScript($CWD/setpin.py)"/>
<setting label="32114" type="action" option="close" action="RunAddon(script.pinsentry)"/>
<setting label="32113" type="action" action="RunScript($CWD/cleanup.py)"/>

After convert

<data>RunScript(C:\Users\admin\AppData\Roaming\Kodi\addons\script.pinsentry\/cleanup.py)</data
<data>RunScript(C:\Users\admin\AppData\Roaming\Kodi\addons\script.pinsentry\/setpin.py,unrestrictedUserPin)</data>

Is this the correct format.
I am trying to migrate Pinsentry add-on from Python 2 to 3 and still stuggling to make it work
The old and new settings.xml file are in the below link

PinSentry_Kodi19

Any help will be appreciated.
I suggest to replace the absolute path C:\Users\AppData\Roaming\Kodi\addons\script.pinsentry\ with $CWD as this is the current working dir of the addon and independent from the used OS/Distribution. Linux and Distributions like Libre-/CoreElec don't have windows paths like this above.
Pages: 1 2 3 4