Can you add a variable to a plugins strings.xml?
#1
Is it possible to pass information from python to the plugins settings string?

for example, can I:

python:

Code:
a_num = str(len(list))


strings.xml:

Code:
<string id="30003">You have %s:</string> % a_num
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#2
First, using strings.xml is depreciated for some time now. Now XBMC/Kodi uses pseudo-Gettext bigingual .po files.

And yes, you can use string formatting variables in your UI string.
Reply
#3
i don't think it can be done with strings used in settings though?
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
(2014-10-14, 10:50)ronie Wrote: i don't think it can be done with strings used in settings though?

Yes, the OP's question is rather vague and I have understood that it is about using formatting variables in UI strings. Maybe the OP could better explain what he/she wants to achieve.
Reply
#5
(2014-10-14, 12:01)Roman_V_M Wrote:
(2014-10-14, 10:50)ronie Wrote: i don't think it can be done with strings used in settings though?

Yes, the OP's question is rather vague and I have understood that it is about using formatting variables in UI strings. Maybe the OP could better explain what he/she wants to achieve.

Thanks for replies, yes I know string.xml is old.. but since I have no chance of getting into the official repo... I'll leave it alone for now.

the example I gave is a crude idea of what I want, I know that it won't work as it is. But it helps get my point across?

What I want is... in python I parse a list, I would like to pass the amount of elements in the list to the string.xml so a user viewing his or her plugin settings would see, "You Have" %dd
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#6
Why not use a "number" setting in the Settings.xml that is "enabled"="false"? It would be greyed-out, unselectable but still visible.

Then you could simply have __addon__.setSetting('YourSetting', YourInt) in your script.
Reply
#7
(2014-10-15, 03:19)Karnagious Wrote: Why not use a "number" setting in the Settings.xml that is "enabled"="false"? It would be greyed-out, unselectable but still visible.

Then you could simply have __addon__.setSetting('YourSetting', YourInt) in your script.

yea... but the range of the elements can be 1 - 1000s thats a lot of unused setting id's just laying around.

if I understand you correctly, that I would setup id's with each number value, enable = false to block them out then switch on the appropriate value.

I might have answered my own question before...since I know my plugin won't be in the official repo (because I perform writes to guisettings, and skin xml's).

Guess I could just open string.xml in python and rewrite the value?
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#8
(2014-10-15, 03:24)Lunatixz Wrote: if I understand you correctly, that I would setup id's with each number value, enable = false to block them out then switch on the appropriate value.

No, just one setting. It is permanently disabled so the user cannot manually change the displayed value, but they can still see it. (Hiding the setting completely would require "visible"="false".)

<setting label="You Have" type="number" enable="false" id="code"/>

I'm am not sure if the number would actually show up, and cant test right now. But I think it does. I know it does for the slider.

The alternative would be to have a single enum setting with every possible number included. That would be awfully bloaty though.
Reply
#9
I have been able to test it, and it does display the number.
Reply
#10
(2014-10-15, 11:54)Karnagious Wrote: I have been able to test it, and it does display the number.

Can u show example? Thanks again
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#11
If I understand what you need correctly, this would be the solution:

Code:
In the Settings.xml:
<setting label="Number of items you have ... " type="number" enable="false" id="code"/>

Code:
In your script:
__addon__        = xbmcaddon.Addon()
__addon__.setSetting( 'code', '952' )
Reply
#12
(2014-10-16, 00:30)Karnagious Wrote: If I understand what you need correctly, this would be the solution:

Code:
In the Settings.xml:
<setting label="Number of items you have ... " type="number" enable="false" id="code"/>

Code:
In your script:
__addon__        = xbmcaddon.Addon()
__addon__.setSetting( 'code', '952' )

Sweet! I'll give it a try... Life saver Smile ahh ic what you did... just set the number...duh... not exactly what I was looking for but it will do Smile
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply

Logout Mark Read Team Forum Stats Members Help
Can you add a variable to a plugins strings.xml?0