XBMC skin script
Made this in 2004 or so with the IRC thingy. Download it here
Docs follow…
xbmc skin reader script 0.1 by bitplane
A nice little thing to make your scripts skinnable. This is pretty much hacked together, but it works okay.
info for skinners:
My skins work a little differently from normal ones…
1) Control and window
2) a controls
3) they can contain python expressions and variables. Variables are created for each of the tags in the root of the
NOTES:
- Variables are ONLY evaluated in the
section and in the , , and of a control. So you can't use them to make up labels, fonts, colours, or other strings (yet). - Variables are evaluated as soon the script reads the line in the xml, so you can’t reference a variable before it’s been created.
- You can change variables as you go along, so you can use temp values for any big or confusing calculations that you need to do. In the following XML, the background image will fall short of the screen height by 10%
If you’re not familliar with programming, it’s worth noting that “10+42” is 18, not 28 as you might expect- multiplication and division are handled before addition and subtraction. use brackets to clarify: “(10+4)2” is 28. Unfortunately, in a script this would probably look more like “((z)+(x))*(y)”, its worth splitting ugly expressions over a few lines and commenting them like in the example above.
GET PAPER AND A PENCIL!
Sketch your screen on the paper and make it look pretty, then give each offset a meaningful name, and work out where about it should be…
Then use the variables to position your controls like in the examples above. You can put big complicated calculations in the controls, but its best to set them up beforehand so you can change your entire layout by editing one value at the top of the xml. Cool huh?
Of course you don’t need to use variables if you don’t want to, but then you’ll need a new script file for every screen mode. haha.
4) Windows within windows.
If no group is set, or if it’s empty or “-“, then no group is assumed and the control is visible at all times. If a group is set, it won’t be visible until the group is active.
If set, the window’s
Alternatively, you can set the window’s
Info for coders:
The main class is XBMC_SKIN, which is derived from xbmcgui.Window So to use it, just subclass it like a normal xbmc.Window. When you override the onAction method, you’ll need to get the control’s ID string from the xml. like so:
def onAction(self, control): id = self.getcontrolid(control)
if id == "btnprivatefiles":
print "dummy button activated! We have a nosey bastard"
the XBMC_SKIN_CONTROL class doesn’t inherrit anything, it links to the control by it’s “control” variable - you’ll need to remember this when you’re referencing the it in the code. It’s: self.controls[“lbloutput”].control.setText(“Push off nosey”)
NOT: self.controls[“lbloutput”].setText(“Push off nosey”)
Perhaps it should be, and I might change this in future. To be honest I couldn’t be arsed with the agro of debugging my first attempt at multiple class inherritance on the xbox.
Class XBMC_SKIN(xbmcgui.Window)
functions: loadskin(“filename”) # loads the skin. the full path must be given getoption(“option”) # returns the window option from .options if it exists # or “” if not, without raising error. showgroup(“group”) # shows all controls with the group name “group” or “” getcontrolid(xbmcgui.Control) # gets the ID of the specified control
variables: path # path to the skin, for getting images options # dictionary of strings containing variables and window # settings, (like window “id”) controls # dictionary of skin controls by ID # ie) controls[“id”] = XBMC_SKIN_CONTROL group # string containing name of last set group
Class XBMC_SKIN_CONTROL()
functions: getoption(“option”) # returns the window option from .options if it exists # or “” if not, without raising error.
variables: owner # back reference to the window control # reference to the actual xbmcgui.Control options # the tags from the xml, ie) if x.options[“width”] == 51
a very short demo…
import xbmcskin
x = xbmcskin.XBMC_SKIN_CONTROL() x.loadskin(“e:\test.xml”) x.doModal()