WindowXML GUI Toolkit (replaces GUIBuilder for XBMC python scripts for GUI coding)
#1
Thumbs Up 
Hello, I finally had some success at adding a new Window Type. (Called WindowXML). The purpose of this is to remove the need for GUIBuilder and let XBMC load the xmls and handle it correctly. This even means onclicks for builtins, animation and visibility should work without the need for tons of python code powering it.

Class xbmcgui.WindowXML()
Function xbmcgui.WindowXML().onInit(self) #Replacement for __init__
Function xbmcgui.WindowXML().onAction(self,action)
Function xbmcgui.WindowXML().onClick(self,controlID) #Replacement for onControl
Function xbmcgui.WindowXML().onFocus(self,controlID)

If anyone is interested in having the onFocus stuff in old Window and WindowDialog please just say.

Ideas/Long Term Goals
XML PATH
Allow you to do specify currentscriptpath + "\\mainwindow.xml" and automatically check path that the xml is in for images (if it has a path) else it’s assumed that the xml is located in the current skin and images are in the media and XPR. Inital ideas are make the scripter detect if the xml they want such as youtube_window.xml is located in the currentskin\pal or NTSC folders else use the included xml/ stock graphics.

More Control Types
Allow for more controls types (port over more the controls available for skinning to be able to do even more.

Change the Way My Scripts works
Allow you to 'minimize' a script, then if you click on the script in my scripts give you the option to maximize or close it. Of course also have an option for scripter. (The maximize would work but remember the Window id given to the script while its running and activating that id when you click it in my scripts.

Way for Type Checking and Error handling
Way to check that when u get the control with id 2 that it is infact a button and a skinner hasn't made it a image instead Smile

Note) I Am going off to uni so i may not get a chance to work on this. Im hoping to create a branch to store my work in before I go.

Example Script showing it from the python scripters side
Code:
import xbmcgui

KEY_BUTTON_BACK = 275
KEY_KEYBOARD_ESC = 61467

"""
    Problems At The Moment
    - Requires the xml to be present in the current running skin (so no way to load a included xml and gfx)
    - Currently you can not get ControlList type returned if you do   self.getControl(id).
        Window.cpp  Window_GetControlByID in the switch(pGUIControl->GetControlType()) needs a case for case CGUIControl::GUICONTAINER_LIST: \_
        and a matching python type. Making it a ControlList causes access issues
    - 'Exiting Problem' if you do use <onclick> in the xml (builtins) [i find u have to activatewindow(13000) 'usually' to show the script again then ESC/BACK to close
"""

"""
    xbmcgui.WindowXML()
    xbmcgui.WindowXML().onInit(self)                Replacement for __init__
    xbmcgui.WindowXML().onAction(self,action)
    xbmcgui.WindowXML().onClick(self,controlID)        Replacement for onControl
    xbmcgui.WindowXML().onFocus(self,controlID)
"""

class WindowXML(xbmcgui.WindowXML):
    def onInit(self):
        """
            This function has been implemented and works
            The Idea for this function is to be used to get initial data and populate lists
        """
        print "onInit(): Window Initialized"
        #self.listctrl = self.getControl(50)
        #self.listctrl.addItem("hey")
        self.button = self.getControl(2) # Example of getting a control based on ID
        self.button.setLabel('Hello 2', 'font14', '0xFFFFFFFF', '0xFFFF3300', '0xFF000000')  # changing the control after its on screen

    def onAction(self, action):
        """"
            onAction in WindowXML works same as on a Window or WindowDialog its for keypress/controller buttons etc
            This function has been implemented and works
        """
        buttonCode =  action.getButtonCode()
        actionID   =  action.getId()
        print "onAction(): actionID=%i buttonCode=%i" % (actionID,buttonCode)
        if (buttonCode == KEY_BUTTON_BACK or buttonCode == KEY_KEYBOARD_ESC):
            self.close()

    def onClick(self, controlID):
        """
            onClick(self, controlID) is the replacement for onControl. It gives an interger.
            This function has been implemented and works
        """
        print "onclick(): control %i" % controlID

        if (controlID == 2):
            print "Some Control with id 2 was pressed"

    def onFocus(self, controlID):
        """"
            onFocus(self, int controlID)
            This function has been implemented and works
        """
        print "onFocus(): control %i" % controlID
        if (controlID == 5):
            print 'The control with id="5" just got focus'

if __name__ == '__main__':
    w = WindowXML("youtube.xml")
    w.doModal()
    del w

Any ideas, suggestions are appreciated.
More information should be up on http://darkdonno.googlepages.com/xbmc-dev once i get around to documenting more of it Smile
Spend quite a few hours today getting the actual code to work so far Smile
The goal is make scripts more like plug-ins that fit along with the rest of XBMC, and also try to make it easier and hopefully more efficient.
** Team XBMC Tester** XBMC 4 ever

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply


Messages In This Thread
WindowXML GUI Toolkit (replaces GUIBuilder for XBMC python scripts for GUI coding) - by donno - 2007-02-14, 14:33
[No subject] - by solexalex - 2007-02-14, 15:30
[No subject] - by Nuka1195 - 2007-02-14, 17:09
[No subject] - by FrostBox - 2007-02-14, 17:40
[No subject] - by matthuisman - 2007-02-15, 01:14
[No subject] - by Asteron - 2007-02-15, 01:45
Reply - by donno - 2007-02-15, 04:28
Update - by donno - 2007-02-17, 07:35
[No subject] - by Nuka1195 - 2007-02-17, 08:29
[No subject] - by spiff - 2007-02-17, 11:39
[No subject] - by asg - 2007-02-21, 14:47
Update - by donno - 2007-02-24, 16:01
[No subject] - by asg - 2007-02-25, 20:16
[No subject] - by matthuisman - 2007-02-25, 20:41
[No subject] - by matthuisman - 2007-02-25, 20:42
[No subject] - by donno - 2007-03-12, 14:04
[No subject] - by Asteron - 2007-03-12, 16:58
[No subject] - by asg - 2007-03-12, 17:21
[No subject] - by Nuka1195 - 2007-03-12, 21:21
[No subject] - by Asteron - 2007-03-12, 21:59
[No subject] - by asg - 2007-03-12, 22:31
[No subject] - by Nuka1195 - 2007-03-12, 23:23
[No subject] - by donno - 2007-03-18, 14:34
[No subject] - by Nuka1195 - 2007-03-18, 15:15
[No subject] - by blittan - 2007-03-18, 16:26
[No subject] - by Jezz_X - 2007-03-18, 20:41
[No subject] - by Asteron - 2007-03-20, 01:11
[No subject] - by donno - 2007-03-20, 05:54
Update - by donno - 2007-03-20, 23:59
[No subject] - by dsvensson - 2007-03-22, 17:18
[No subject] - by donno - 2007-04-02, 08:22
[No subject] - by Nuka1195 - 2007-04-04, 23:39
[No subject] - by matthuisman - 2007-04-07, 09:51
[No subject] - by Nuka1195 - 2007-04-07, 16:31
[No subject] - by matthuisman - 2007-04-08, 02:47
[No subject] - by Nuka1195 - 2007-04-08, 16:06
[No subject] - by matthuisman - 2007-04-09, 11:34
[No subject] - by matthuisman - 2007-04-10, 14:03
[No subject] - by matthuisman - 2007-04-10, 14:04
[No subject] - by Nuka1195 - 2007-04-10, 15:46
[No subject] - by matthuisman - 2007-04-11, 00:09
[No subject] - by Nuka1195 - 2007-04-11, 00:26
[No subject] - by asg - 2007-04-11, 00:31
[No subject] - by asg - 2007-04-11, 00:35
[No subject] - by matthuisman - 2007-04-11, 03:05
[No subject] - by Nuka1195 - 2007-04-11, 03:13
[No subject] - by matthuisman - 2007-04-11, 06:39
[No subject] - by matthuisman - 2007-04-11, 06:41
[No subject] - by donno - 2007-04-11, 08:54
[No subject] - by Nuka1195 - 2007-04-11, 16:08
[No subject] - by matthuisman - 2007-04-12, 00:04
[No subject] - by Nuka1195 - 2007-04-12, 00:26
Reply - by donno - 2007-04-12, 03:40
[No subject] - by matthuisman - 2007-04-12, 05:41
[No subject] - by matthuisman - 2007-04-13, 02:24
[No subject] - by matthuisman - 2007-04-13, 02:42
[No subject] - by jmarshall - 2007-04-13, 03:33
[No subject] - by Nuka1195 - 2007-04-13, 04:12
[No subject] - by matthuisman - 2007-04-13, 05:00
[No subject] - by matthuisman - 2007-04-13, 05:03
[No subject] - by Nuka1195 - 2007-04-13, 15:27
[No subject] - by matthuisman - 2007-04-13, 16:16
[No subject] - by matthuisman - 2007-04-13, 16:20
[No subject] - by matthuisman - 2007-04-13, 16:22
[No subject] - by Nuka1195 - 2007-04-13, 17:42
[No subject] - by matthuisman - 2007-04-14, 01:46
[No subject] - by matthuisman - 2007-04-14, 09:00
[No subject] - by Nuka1195 - 2007-04-18, 17:12
[No subject] - by matthuisman - 2007-04-19, 00:07
[No subject] - by Nuka1195 - 2007-04-19, 01:47
[No subject] - by matthuisman - 2007-04-19, 02:07
[No subject] - by Nuka1195 - 2007-04-20, 15:23
[No subject] - by Nuka1195 - 2007-04-23, 00:49
-- - by donno - 2007-04-24, 14:31
[No subject] - by Nuka1195 - 2007-04-24, 15:00
[No subject] - by Nuka1195 - 2007-04-24, 16:53
[No subject] - by Nuka1195 - 2007-04-24, 18:19
[No subject] - by matthuisman - 2007-04-25, 01:05
[No subject] - by Nuka1195 - 2007-04-25, 04:17
[No subject] - by matthuisman - 2007-04-25, 05:21
[No subject] - by jmarshall - 2007-04-25, 07:32
[No subject] - by Nuka1195 - 2007-04-25, 17:13
[No subject] - by matthuisman - 2007-04-28, 14:12
[No subject] - by Nuka1195 - 2007-04-28, 15:02
[No subject] - by Nuka1195 - 2007-04-28, 17:34
[No subject] - by Nuka1195 - 2007-04-28, 19:18
[No subject] - by matthuisman - 2007-04-29, 01:12
[No subject] - by l8tig - 2007-05-06, 12:41
[No subject] - by Nuka1195 - 2007-05-06, 15:44
[No subject] - by l8tig - 2007-05-06, 16:02
[No subject] - by Nuka1195 - 2007-05-08, 17:48
[No subject] - by donno - 2007-05-10, 13:43
[No subject] - by Nuka1195 - 2007-05-10, 15:46
[No subject] - by jmarshall - 2007-05-10, 23:57
[No subject] - by Nuka1195 - 2007-05-11, 02:27
[No subject] - by Nuka1195 - 2007-05-12, 15:11
[No subject] - by donno - 2007-05-13, 12:39
[No subject] - by Nuka1195 - 2007-05-13, 13:59
[No subject] - by mrz - 2007-05-16, 11:19
[No subject] - by Nuka1195 - 2007-05-16, 22:30
[No subject] - by Basje - 2007-05-17, 23:28
[No subject] - by mrz - 2007-05-18, 17:12
[No subject] - by mrz - 2007-05-18, 17:16
[No subject] - by Nuka1195 - 2007-05-18, 18:57
[No subject] - by mrz - 2007-05-18, 20:52
[No subject] - by Nuka1195 - 2007-05-18, 21:33
[No subject] - by mrz - 2007-05-18, 22:53
[No subject] - by mrz - 2007-05-18, 23:47
[No subject] - by mrz - 2007-05-19, 00:00
[No subject] - by Nuka1195 - 2007-05-19, 00:11
[No subject] - by mrz - 2007-05-19, 00:18
[No subject] - by matthuisman - 2007-05-23, 00:05
[No subject] - by Nuka1195 - 2007-05-24, 00:49
[No subject] - by Nuka1195 - 2007-05-25, 00:44
[No subject] - by Gamester17 - 2007-05-25, 08:59
[No subject] - by donno - 2007-05-27, 13:40
WIKI article needed... - by Gamester17 - 2007-05-27, 13:59
WindowXML Update - by donno - 2007-06-03, 07:51
[No subject] - by Nuka1195 - 2007-06-05, 17:55
[No subject] - by Basje - 2007-06-05, 23:13
[No subject] - by matthuisman - 2007-06-06, 05:04
[No subject] - by Basje - 2007-06-06, 08:27
Donno - by donno - 2007-06-06, 10:10
[No subject] - by Basje - 2007-06-06, 10:40
[No subject] - by matthuisman - 2007-06-11, 21:34
[No subject] - by Basje - 2007-06-11, 21:50
[No subject] - by Nuka1195 - 2007-07-06, 16:44
[No subject] - by Nuka1195 - 2007-07-12, 02:22
[No subject] - by jmarshall - 2007-07-12, 02:56
[No subject] - by Nuka1195 - 2007-07-12, 04:24
[No subject] - by jmarshall - 2007-07-12, 04:31
[No subject] - by mrz - 2007-07-13, 11:29
[No subject] - by Basje - 2007-07-22, 12:19
[No subject] - by Nuka1195 - 2007-07-22, 14:04
[No subject] - by Basje - 2007-07-22, 14:27
[No subject] - by Nuka1195 - 2007-07-23, 03:15
[No subject] - by jc85 - 2007-07-23, 13:46
[No subject] - by Nuka1195 - 2007-07-23, 14:14
[No subject] - by jc85 - 2007-07-23, 15:25
[No subject] - by Nuka1195 - 2007-07-23, 15:29
[No subject] - by jc85 - 2007-07-23, 15:40
[No subject] - by Nuka1195 - 2007-07-23, 16:12
[No subject] - by jc85 - 2007-07-23, 16:12
[No subject] - by Nuka1195 - 2007-07-23, 16:28
[No subject] - by jc85 - 2007-07-23, 16:42
[No subject] - by Nuka1195 - 2007-07-23, 16:44
[No subject] - by Basje - 2007-07-23, 19:02
[No subject] - by Nuka1195 - 2007-07-23, 22:00
[No subject] - by jc85 - 2007-07-23, 22:39
[No subject] - by Freddo - 2007-07-24, 03:05
[No subject] - by jc85 - 2007-07-24, 03:50
[No subject] - by Freddo - 2007-07-24, 03:59
[No subject] - by jc85 - 2007-07-24, 04:08
[No subject] - by Basje - 2007-07-24, 23:39
[No subject] - by Nuka1195 - 2007-07-25, 00:40
[No subject] - by Basje - 2007-07-25, 08:19
[No subject] - by chunk_1970 - 2007-08-10, 11:21
[No subject] - by Basje - 2007-08-10, 11:25
[No subject] - by chunk_1970 - 2007-08-10, 11:29
[No subject] - by chunk_1970 - 2007-08-10, 11:38
[No subject] - by Nuka1195 - 2007-08-10, 14:00
[No subject] - by chunk_1970 - 2007-08-10, 15:50
[No subject] - by Nuka1195 - 2007-08-10, 16:11
[No subject] - by jmarshall - 2007-08-11, 00:25
[No subject] - by chunk_1970 - 2007-08-11, 15:08
[No subject] - by bortoni - 2007-08-20, 16:48
[No subject] - by Nuka1195 - 2007-08-21, 02:59
[No subject] - by Nuka1195 - 2007-09-16, 19:22
[No subject] - by Nuka1195 - 2007-09-17, 22:57
[No subject] - by jmarshall - 2007-09-17, 23:23
[No subject] - by Nuka1195 - 2007-09-18, 15:27
[No subject] - by BigBellyBilly - 2008-02-29, 15:26
[No subject] - by borick - 2008-08-29, 23:26
[No subject] - by Gamester17 - 2008-08-29, 23:34
[No subject] - by borick - 2008-08-30, 23:02
[No subject] - by jmarshall - 2008-12-18, 23:32
[No subject] - by Basje - 2008-12-18, 23:47
[No subject] - by Nuka1195 - 2008-12-19, 00:31
[No subject] - by catalytic - 2008-12-19, 05:36
[No subject] - by Nuka1195 - 2008-12-19, 16:17
[No subject] - by catalytic - 2008-12-20, 20:06
Logout Mark Read Team Forum Stats Members Help
WindowXML GUI Toolkit (replaces GUIBuilder for XBMC python scripts for GUI coding)0