PDA

View Full Version : Sending arguments to scripts integrated into skins


Asteron
2007-02-24, 22:28
Alot of skins are now integrating python scripts to change things normally not possible (ie change font color or swapping the splash screen (http://xbmc.org/forum/showthread.php?t=24955)). A problem though is that the script has to put up its own gui to present the user with a selection or whatever (like a choice of font colors).

In Rev 5908 I added the ability to send arguments to scripts via the XBMC.RunScript builtin. This means instead of

<onclick>XBMC.RunScript(Q:\skin\Project Mayhem III\extras\fontcolor.py)</onclick>

which makes the script bring up its own GUI, you can just have a button in the skin call:

<onclick>XBMC.RunScript(Q:\skin\Project Mayhem III\extras\fontcolor.py,FFFF00FF)</onclick>

And have the script just process the color from the argument.

This should simplify the python alot and keep the GUI in the skin where it belongs and is easy to change.

Scripters can follow the following guide on the wiki to using arguments http://www.xboxmediacenter.com/wiki/index.php?title=Building_Scripts#Script_Arguments

Skinners should take note of the updated XBMC.RunScript definition here
http://www.xboxmediacenter.com/wiki/index.php?title=List_of_Built_In_Functions

Nuka1195
2007-02-25, 00:26
This addition is great, but it breaks sys.path[0] when launching a script from another script.

If any scripts use sys.path[0], they need to switch to:
os.getcwd().replace( ";", "" ).

Asteron
2007-02-25, 01:27
Are you saying that sys.path is set when launching a script from
xbmc.runscript(script)
but not from
xbmc.executebuiltin("XBMC.RunScript("+script+")")
? Really os.getcwd is what you want I think. But yeah I expect for this to be the most useful for skins that talk to scripts...