WindowXML

From XBMC
(Redirected from WindowXML GUI Toolkit)
Jump to: navigation, search
Incomplete.png INCOMPLETE:
This page or section is incomplete. Please add information or correct uncertain data which is marked with a ?
Time.png OUTDATED:
Some information in this article or section has not been updated or refers to XBMC features that have been superseded, and may not be reliable.

WindowXML is a class available in the python scripting side of XBMC. The WindowXML GUI Toolkit is an application framework that allow python scripters to create dynamic windows from an XML file, just like how XBMC skinners creates windows from XML for Home, Music, Programs windows, and similar to how GUIBuilder.py (a library written in python for XBMC) can take the XML and make a window, how ever it was limited solely to controls that existed in XBMC and involved having to add extra stuff to the controls in order to give more control over the creation of controls, WindowXML uses the WindowXML class in XBMC for creating windows from XML, so it will always use the same XML format/style, as XBMC.

This page is meant for python scripters using XBMC to create their scripts, not really useful for general users.


Contents

1 class WindowXML

The WindowXML class, inherits Window it includes what is called a 'WindowList' more about below.

1.1 Constructor

1.1.1 WindowXML(self, XMLname, fallbackPath[, defaultskinname, forceFallback])

2 Window Lists

WindowXML has has what are termed 'Window Lists'. its a List thats actually stored in the window. It can be viewed using Lists or Panel Controls with id 50 to 59, and is accessed by using methods on the actual windowxml class, 'self.addItem("Hello")'

2.1 Methods

Methods for controlling and accessing the WindowLists

2.2 Controls

TODO) Write about how to use controls. (A Start) The key to using WindowXML is by id, onClick and onFocus both give you the ID of the control clicked (not a 'control object' like normal Python Windows and Dialogs do. To set visiblity on controls or change labels etc use .getControl(ID) which will return a object of the control type (provided it has a python equivalent). Need to see about having a generic control return if its not, its on the TODO list.

Important if you don't want to use the WindowLists you still need to remember not to use the ids for other stuff.

2.3 Base 'FrameWork' for a WindowXML

class MyFirstWinXML(xbmcgui.WindowXMLDialog):
    def __init__(self,strXMLname, strFallbackPath, strDefaultName, forceFallback):
        # Changing the three varibles passed won't change, anything
        # Doing strXMLname = "bah.xml" will not change anything.
        # don't put GUI sensitive stuff here (as the xml hasn't been read yet
        # Idea to initialize your variables here
        pass
 
    def onInit(self):
        # Put your List Populating code/ and GUI startup stuff here
        pass 
 
    def onAction(self, action):
        # Same as normal python Windows.
        pass
 
    def onClick(self, controlID):
        """
            Notice: onClick not onControl
            Notice: it gives the ID of the control not the control object
        """
        pass
 
    def onFocus(self, controlID):
        pass

3 Default Skin

The idea behind it is scripts using WindowXML should always come with a default skin, which shouldn't rely on includes and defaults, meaning all the tags for the controls should be implicitly defined so it will look the same regardless of skins. It should also include all the graphics such as backgrounds for a skins. Images should be uniquely named like defaultYoutubeBackground.png or dYoutubeBackground.png so it doesn't conflicts with a file of the same name included with a skin. Fonts are currently out of your control, scripters have no way of loading their own TTF fonts in and using them.

4 Fallback Explained

By default forceFallback is 'false' so it won't diminish looking in the current skins folder. Note: media doesn't fallback the same way. If an image has the same name as one in the current skin it will use that, this is due to the way XBMC media/texture handling works. For the 'DefaultSkin' its best to choose names that are unique so it won't conflict with a skin.

Summary, is it will keep 'falling back' until it hopefuly finds it. Its set up so it will always check the pal folder just for consistency. Note: XBMC holds its skins in a folder call skin, but for in the fallbackpath (typically script folder) use the folder skins

4.1 Example

Let’s assume, your running Project Mayhem III, in 720p, and XMLName is Script_WindowXMLExample.xml, and fallback path is q:\scripts\WinXMLExample\ and Default skin name is 'DefaultSkin' WindowXML will check

It progresses onto the next path if it can't find it. Note: pal_16x9 may not be guaranteed based on the fact it depends on the skin.xml in the skin what the default resolution. However it always will end up in 'pal' as a safe guard.

See CSkinInfo::GetSkinPath in Skininfo.cpp and WindowXML_New in winxml.cpp for the code for how fallback works

5 See also

Development:

Personal tools
Namespaces
Variants
Actions
Navigation
Wiki help
Google Search
Toolbox