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
Dan Dare Offline
http://www.xbmc4xbox.org
Posts: 1,039
Joined: Sep 2004
Reputation: 146
Post: #31
@digitaldesaster
The first post says it pretty clearly, this is for plugins, not scripts.
find quote
digitaldesaster Offline
Junior Member
Posts: 33
Joined: Aug 2009
Reputation: 0
Post: #32
In Germany whe say: "Wer lesen kann ist klar im Vorteil". sorry..

cya
dd
find quote
f3ar007 Offline
Member
Posts: 57
Joined: Apr 2009
Reputation: 0
Post: #33
Hi, I'm trying to use the "enum" plugin setting; however, it reads the place in "enum" line, for instance:

The settings.xml:
Code:
<settings>
    <setting id="username" type="text" label="Username:" default="enter user"/>
    <setting id="password" type="text" label="Password:" default="enter pass"/>
    <setting id="archiveMonth" type="enum" label="Month:" values="01|02|03|04|05|06|07|08|09|10|11|12" default="01"/>
    <setting id="archiveDay" type="enum" label="Day:" values="01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27​|28|29|30|31" default="01"/>
    <setting id="archiveYear" type="enum" label="Year:" values="2009|2010" default="2009"/>
</settings>

The python code:
Code:
archiveMonth = xbmcplugin.getSetting('archiveMonth')
archiveDay = xbmcplugin.getSetting('archiveDay')
archiveYear = xbmcplugin.getSetting('archiveYear')
archiveDate = '/' + str(archiveMonth) + '-' + str(archiveDay) + '-' + str(archiveYear) + '/'
str(archiveDate)

If 11-13-2009 is selected, the returned value *should* be /11-13-2009/; instead, it returns /10-12-0/ or very similar. **The number in line, beginning at zero. Is there a way to get the actual value from the "enum" setting, instead of its ordinal value?
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 26,228
Joined: Oct 2003
Reputation: 177
Post: #34
I believe that's what the enum does - it returns the index rather than the value. If you want the value you should know it anyway, right (after all, you supplied the values). For consecutive numbers with a min and a max you can probably do it without the enum at all, right? The enum stuff is designed for non-consecutive numbers.

Cheers,
Jonathan

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
f3ar007 Offline
Member
Posts: 57
Joined: Apr 2009
Reputation: 0
Post: #35
Well, I am trying to create a sort of calendar like select. (Should be obvious by the example. Laugh) Although, I'm not sure how I could accomplish this without the "enum" option. Is there a better way?

This is a feature request for one of my plugins. The users mentioned entering dates was a long process, this will hopefully speed it up! Cool

## Figured this one out...

Just checked the length of the "enum" index and returned a zero in front of single digits or nothing in front of double digits.
Checked the year against a string.
(This post was last modified: 2009-11-14 12:04 by f3ar007.)
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #36
<setting id="archiveDay" type="labelenum"

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
VictorV Offline
Senior Member
Posts: 124
Joined: May 2009
Reputation: 1
Location: Norway
Post: #37
Would it be possible to create a slider option? With min, max and step size?
find quote
spiff Offline
Retired Developer
Posts: 12,386
Joined: Nov 2003
Post: #38
possible, yes, available, no.
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #39
i already submitted a ticket for this along time ago. among others.

spiff or anybody check out that settings cleanup ticket. a comment would have been nice.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
D0nR0s4 Offline
Senior Member
Posts: 280
Joined: Nov 2009
Reputation: 0
Location: Germany
Post: #40
Hi, just saw the possibility for the settings.xml and it works like a charm. Only thing that I would like/need for my script, is the possibility to select a hard or cd/dvd drive.
I mainly need the letter(on Windows) of the dvd drive from which I get the state with "getDVDState". I didn't find anything about this so I thought I could use a settings entry but I found no chance to select the dvd drive with the folder or file setting types.

I hope someone can help me,
Greetings,
D0nR0sa

Edit: Sorry, problem was an error in xbmc that prevented me from accessing the dvd drive
(This post was last modified: 2009-12-27 06:49 by D0nR0s4.)
find quote
Spaggi Offline
Senior Member
Posts: 179
Joined: May 2010
Reputation: 0
Post: #41
I can't use the settings type "Files". If I use it like this:

Quote: <setting id="Files01" type="files" label="30012" default="" />

It won't show up in the settings menu...what am I doing wrong?
(This post was last modified: 2010-07-25 19:53 by Spaggi.)
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #42
type="file"

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Spaggi Offline
Senior Member
Posts: 179
Joined: May 2010
Reputation: 0
Post: #43
Works, thanks alot!

Another issue: When I use fileenum, I cannot find .m3u playlist files. Txt files work well.
find quote
solexalex Offline
Skilled Python Coder
Posts: 707
Joined: Jul 2004
Reputation: 6
Post: #44
Hello !
three questions :

1 - Any new infos where we can get help on all available settings, how they works, what are the options and their possible values... ?


2 - It looks like bool setting can't get the option 'visible' ... Why ?

3 - I used the setting type 'action' but the default value, which is the command line (RunPlugin(....) ) is showing next to the label. Any way to hide it ?

(I'm using XBMC 9.11 r26017)
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #45
1. in guidialogaddonsettings.cpp (i think)
2. it should, maybe a bug
3. put the action in action="RunScript()" leave default blank. default=""

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Post Reply