how to bring data value from python to xml file
#1
Hi,

In my issue...I have created a custom dialog box which will be activated through python script what I need is I want to dialog box which is in xml to take a data value from python and show it as a string in xml dialog box.

In mean I want to put in lable <lable> data value from python </lable>...

How can i do that?

thanks for all
Reply
#2
BTW, questions like this would be better asked in the addon development section of the board as it isn't Linux specific Wink


You put something like this in your python script.
Code:
import xbmcgui
WINDOW = xbmcgui.Window(10000) # That window ID is for the home window
WINDOW.setProperty("myDataValue", x)

Then you display it in your skin with
Code:
<label>$INFO[Window(Home).Property(myDataValue)]</label>
 
There is a list of window ID's here

The documentation for xbmcgui.setProperty is here
Learning Linux the hard way !!
Reply
#3
Yeah thank you..maybe I thought because it's scripting issue it is for Linux  Tongue  Next time will recognize this issue in my account

very nice I will try it!  Nerd

what if my script has :


if data == "101":
    xbmc.executebuiltin('ActivateWindow(1199)')
elif data == "102":
   xbmc.executebuiltin('ActivateWindow(1188)')

then the label in window 1199 which is activated because data = 101 then I want to show number 101 .

thanks for your valued support
Reply
#4
Nice it works! many thanks

I have question  Rolleyes  Why I put the ID of Home window but the window ID which is activated is 1199! but it works and took the data value in label

And what if I want to add string before myDataValue for example: "my height is" + x !
Reply
#5
I added before "$INFO[Window(Home).Property(myDataValue)]" and works awesome!

but still why I put home ID instead of another ID? Huh
Reply
#6
If you set a window property, then you can access it in any window by using <label>$INFO[Window(windowID).Property(my_property)]</label> so you need a line similar to that in your xml file for window 1199 and you can set it with something like

Code:
import xbmcgui
window_id = xbmcgui.Window(10000)
window_id.setProperty("my_data", data)
if data == "101":
    xbmc.executebuiltin('ActivateWindow(1199)')
elif data == "102":
    etc etc

Then in the xml file for window 1199 you would put

Code:
<label>$INFO[Window(10000).Property(my_data)]</label>
and it will display whatever value data is set to in your script.  You would do the same thing for window 1188 to display the value there too.  Although, if the value will always be 101 in window 1199 and 102 in window 1188 the you could just hard-code the values into the xml file as you already know that only that value opens that particular window.

If however, the 'data' value can be multiple values for opening a particular window then the code above will display the actual value, regardless of what it is set to.  Setting window properties and then accessing them through the xml file for the window is how you can display ANY value or string from a script which makes it an extremely useful thing to be able to do.
Learning Linux the hard way !!
Reply

Logout Mark Read Team Forum Stats Members Help
how to bring data value from python to xml file0