HOW-TO write GUI settings for XBMC python plugins and scripts (addons)

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Nuka1195 Online
Skilled Python Coder
Posts: 3,938
Joined: Dec 2004
Reputation: 17
Post: #11
You may now use the browse dialog for a setting. (not merged in linux branch)
You may also use separators now

The following types are now valid:
keyboard:
"text"

ip dialog
"ipaddress"

numeric dialog
"integer"

browse dialogs:
"video", "music", "pictures", "folder", "programs", "files"

radio button:
"bool"

spinners
"enum"

separator
"sep"

There are two new attributes "option", "source":

eg. "option" can be "hidden" for type "text", this will hide the text, though it still displays in the dialog, so this needs looking at. Smile

eg. "source" is used for the browse dialog
Code:
<setting id="path" type="folder" source="video" label="30000" default="F:\videos" />

source can be:"video", "music", "pictures", "programs", "files", "local" or blank.
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.

Code:
[SIZE=2][SIZE=2]<?xml version="1.0" encoding="utf-8" standalone="yes"?>[/SIZE]
[SIZE=2]<settings>[/SIZE]
[SIZE=2]   <setting id="path" type="folder" source="video" label="30000" default="F:\videos" />[/SIZE]
[SIZE=2]   <setting type="sep" />[/SIZE]
[SIZE=2]   <setting id="coming_attraction_videos" type="video" label="30010" default="" />[/SIZE]
[SIZE=2]   <setting id="feature_presentation_videos" type="video" label="30020" default="" />[/SIZE]
[SIZE=2]   <setting id="end_presentation_videos" type="video" label="30030" default="" />[/SIZE]
[SIZE=2]   <setting type="sep" />[/SIZE]
[SIZE=2]   <setting id="use_db" type="bool" label="30040" default="false" />[/SIZE]
[SIZE=2]   <setting id="limit_query" type="bool" label="30050" default="true" />[/SIZE]
[SIZE=2]   <setting type="sep" />[/SIZE]
[SIZE=2]   <setting id="rating" type="enum" values="G|PG|PG-13|R|NC-17|--" label="30060" default="--" />[/SIZE]
[SIZE=2]   <setting id="number_trailers" type="enum" values="0|1|2|3|4|5" label="30070" default="3" />[/SIZE]
[SIZE=2]   <setting id="quality" type="enum" values="Low|Medium|High|480p|720p|1080p" label="30080" default="High" />[/SIZE]
[SIZE=2]   <setting id="only_hd" type="bool" label="30090" default="false" />[/SIZE]
[SIZE=2]</settings>[/SIZE]

[/SIZE]

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
asg Offline
Member
Posts: 80
Joined: Nov 2005
Reputation: 0
Post: #12
What do you guys think about adding a settings dialog to "normal" scripts?
find quote
Nuka1195 Online
Skilled Python Coder
Posts: 3,938
Joined: Dec 2004
Reputation: 17
Post: #13
Quote:
changed: Plug-in settings now have an option "enable" attribute to enable a setting based on the value of another setting.

format: comparator(controls relative pos, value to compare)

comparators are: "eq"=equal to, "!eq"=not equal to, "gt"=greater than, "lt"=less than

only and "+" is supported currently, separate comaparisons with "+" minus quotes.

eg: enable="gt(-1,3) + !eq(-2,0)"

Some additions

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
hani Offline
Junior Member
Posts: 37
Joined: May 2007
Reputation: 0
Post: #14
It would be nice if we have conditional visibility. I think Its more useful than the enable
option. I have many settings in my plugin and they only need to be visible if the user select one option. I guess I could do that in the plugin itself. I will try to submit a batch if you guys accept the idea.:confused2:
find quote
Nuka1195 Online
Skilled Python Coder
Posts: 3,938
Joined: Dec 2004
Reputation: 17
Post: #15
There is now a "visible" attribute, works like the "enable" attribute.

Plugins now have localized strings also, same file as plugin settings.

Remember plugins/plugin settings id numbers are 30000-30999.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
hani Offline
Junior Member
Posts: 37
Joined: May 2007
Reputation: 0
Thumbs Up    Post: #16
Nuka1195 Wrote:There is now a "visible" attribute, works like the "enable" attribute.

Plugins now have localized strings also, same file as plugin settings.

Remember plugins/plugin settings id numbers are 30000-30999.

Wow! Xmas came so early.Thank you guys for the great work.
find quote
Nuka1195 Online
Skilled Python Coder
Posts: 3,938
Joined: Dec 2004
Reputation: 17
Post: #17
Quote:
changed: added "fileenum" plugin setting type with optional "mask". this setting is filled automatically based on the mask and path you set with the "values" attribute. the path is based on your plugins current directory. Use / for your mask to return only folders
eg <setting id="scraper" type="fileenum" mask="/" values="showtimesAPI\scrapers\" label="30510" default="Google" />

Thanks JMarshall and d4rk for your help

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
doze Offline
Junior Member
Posts: 26
Joined: Aug 2004
Reputation: 0
Post: #18
Is there any type to use in plugin settings to input password? I mean that the text would then be displayed as stars or dots or something?

And is there any page in Wiki yet for general info on plugin development?
find quote
doze Offline
Junior Member
Posts: 26
Joined: Aug 2004
Reputation: 0
Post: #19
Hello, anyone?

Also while I'm on the subject, where can I see that what attributes and their values are available for the plugin settings xml for example?

And when I'm creating xbmcgui.ListItem in my plugin and using the setInfo() to set the "attributes" of the video list item, where I can see that in what format should the size and duration and date be, for example?

I cannot seem to find any documentation about plugin development, other than this and that doesn't cover much. I can look from the source too, but I don't know where to look for example when I want to see what's possible to use in plugin settings xml or in what format should the date be when setting it to xbmcgui.ListItem.

Please, help Big Grin
find quote
adityaag Offline
Junior Member
Posts: 31
Joined: Dec 2008
Reputation: 0
Post: #20
I was wondering if there's any place to get more detail on how the enable attribute works? I've tried enable="1" and enable="true" flat out and the option is still disabled. Leaving it out enables it again.

Basically I want a setting to be enabled only if the bool setting above it is true. I played around with some of the eq functions without much avail. Help would be much appreciated.
find quote
Post Reply