Help with Simple Script
#1
Question 
Guys, can anyone genius here figure out why this script crashes 100% when OK is pressed in the simple DialogOK.xml-created dialog? This is the WindowXMLExample script. The DialogOK.xml is the one that comes with XBMC.

Thanks, any help would really be appreciated.

Code:
import xbmcgui
import os

KEY_BUTTON_BACK = 275
KEY_KEYBOARD_ESC = 61467

__title__ = "Window XML Example"


scriptPath = os.getcwd().replace(';','')

class WindowXMLExample(xbmcgui.WindowXML):
    def __init__(self,strXMLname, strFallbackPath,strDefaultName,bforeFallback=0):
        self.url = "http://xboxmediacenter.com"

    def onInit(self):

        print "onInit(): Window Initalized"
        for x in range(0,10):
            self.addItem(xbmcgui.ListItem(("Hello %i" % x),("World %i" % x), "defaultVideo.png", "defaultVideoBig.png"))
            self.addItem(xbmcgui.ListItem(("Test %i"  % x),("Hey %i"   % x), "defaultVideo.png", "defaultVideoBig.png"))
        self.button = self.getControl(99)
        self.button.setLabel('Add to List', 'font14', '0xFFFFFFFF', '0xFFFF3300', '0xFF000000')  # changing the control after its on screen

    def onAction(self, action):
        buttonCode =  action.getButtonCode()
        actionID   =  action.getId()
        print "onAction(): actionID=%i buttonCode=%i" % (actionID,buttonCode)
        if (buttonCode == KEY_BUTTON_BACK or buttonCode == KEY_KEYBOARD_ESC or buttonCode == 61467):
            self.close()

    def onClick(self, controlID):
        print "onclick(): control %i" % controlID
        if (controlID == 7):
            dialog = WindowXMLDialogExample("DialogOK.xml",os.path.join(scriptPath,'DefaultSkin'))
            dialog.setHeading(__title__ + ": About")
            dialog.setLines("Example Script coded by Donno :D","WindowXML Class coded by Donno","With help from Spiff and jmarshall :)")
            dialog.doModal()
            del dialog

        elif (controlID == 13):
            self.clearList()
        elif (controlID == 99):
            for x in range(0,10):
                self.addItem(xbmcgui.ListItem(("Hello %i" % x),("World %i" % x), "defaultVideo.png", "defaultVideoBig.png"))
                self.addItem(xbmcgui.ListItem(("Test %i"  % x),("Hey %i"   % x), "defaultVideo.png", "defaultVideoBig.png"))
        elif (50 <= controlID <= 59):
            print "CurrentListPosition: %i" % self.getCurrentListPosition()
            selItem = self.getListItem(self.getCurrentListPosition())
            print "Selected List Item: Label: %s  Label 2 %s" % (selItem.getLabel(),selItem.getLabel2())
            print "List Item 2: Label: %s   Label 2: %s" % (self.getListItem(2).getLabel(),self.getListItem(2).getLabel2())
            
    def onFocus(self, controlID):
        print "onFocus(): control %i" % controlID
        if (controlID == 5):
            print 'The control with id="5" just got focus'

class WindowXMLDialogExample(xbmcgui.WindowXMLDialog):
    def __init__(self,strXMLname, strFallbackPath):
        self.url = "http://xboxmediacenter.com"
        self.heading = ""
        self.line1 = ""
        self.line2 = ""
        self.line3 = ""

    def onInit(self):
        print "onInit(): Window Initalized"
        self._setLines()

    def onAction(self, action):
        buttonCode =  action.getButtonCode()
        actionID   =  action.getId()
        print "onAction(): actionID=%i buttonCode=%i" % (actionID,buttonCode)
        if (buttonCode == KEY_BUTTON_BACK or buttonCode == KEY_KEYBOARD_ESC or buttonCode == 61467):
            self.close()

    def onClick(self, controlID):
        print "onclick(): control %i" % controlID
        if (controlID == 10):
            self.close()

    def onFocus(self, controlID):
        print "onFocus(): control %i" % controlID

    def _setLines(self):
        self.getControl(1).setLabel(self.heading)
        self.getControl(2).setLabel(self.line1)
        self.getControl(3).setLabel(self.line2)
        self.getControl(4).setLabel(self.line3)

    def setHeading(self, heading):
        self.heading = heading

    def setLines(self, line1,line2, line3):
        self.line1 = line1
        self.line2 = line2
        self.line3 = line3

if __name__ == '__main__':
    w = WindowXMLExample("Script_WindowXMLExample.xml",scriptPath,"DefaultSkin")
    w.doModal()
    del w
Reply
#2
is this on xbmc_pc or the xbox. xbmc_pc sometimes has issues for me closing dialogs. try putting a sleep just before the self.close()
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
This is on the xbmc_pc. I added xbmc.sleep(5) and took care of that crash.

Thanks!
Reply
#4
Nuka1195 Wrote:is this on xbmc_pc or the xbox. xbmc_pc sometimes has issues for me closing dialogs. try putting a sleep just before the self.close()

Good! i thought this was only happening to me.
Reply
#5
Please supply the skin file(s) as well so I can see if I can reproduce the crash and figure out what's going on.
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
#6
Jmarshall, you couldn't last time I brought this up, maybe a debug/release thing.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#7
jmarshall Wrote:Please supply the skin file(s) as well so I can see if I can reproduce the crash and figure out what's going on.

All I did was grab the T3CH build and the WindowXMLExample from the scripts dir in SVN.

There is an About Button that brings up a dialog. Hitting OK on it was crashing for me.
Reply
#8
For me, its intermittant, only with dialogs. Even xbmc built in dialogs as well as winxml dialogs. I will try to get a debug log (it only started recently tho, it used to aprox. 1-2months ago work fine)
Reply
#9
I couldn't get it to crash at all - neither debug or release (XBMC_PC this is).

If it's only on xbox, then I can try that later as well.
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
#10
Nope, only on xbmc_pc, it might be fixed in a later relase (i havn't mucked around with python for the last couple of weeks), but did notice xbmc_pc did seem abit more stable lately with dialogs etc
Reply

Logout Mark Read Team Forum Stats Members Help
Help with Simple Script0