Exiting Plugin
I think this will do it:

win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
win.onAction = do_work

def do_work(action):
    if action == ACTION_NAV_BACK:
        print "Bye now!"
Hmm, I don't think one can override that - I used:

                'ACTION_PARENT_DIR'       :9,
                'ACTION_PREVIOUS_MENU'    :10
ACTION_NAMES = swap_dictionary(ACTION_CODES)

def onActionHere( self, action ):
        actionNum = action.getId()
        actionName = ACTION_NAMES[actionNum]
    except KeyError:
        actionName = None

    if actionName is not None:

win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
win.onAction = onActionHere

..adn this give me:

11:13:41 T:1264   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.AttributeError'>
                                            Error Contents: 'xbmcgui.Window' object attribute 'onAction' is read-only
                                            Traceback (most recent call last):
                                              File "C:\Users\X\AppData\Roaming\XBMC\addons\plugin.program.xsqueezechooser\default.py", line 383, in <module>
                                                win.onAction = onActionHere
                                            AttributeError: 'xbmcgui.Window' object attribute 'onAction' is read-only
                                            -->End of Python script error report<--

...so I think onAction can't be touched like this??
Sorry, no help w/out a *full debug log*
Damn, looks like onAction is coded specifically so it can't be overridden.
Maybe you can catch when the window is destroyed? Try this:
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
win.__del__= onActionHere

The last option that I can think of is to run a small service. Set a window property, then check for it in your service. When it's no longer set on the current window, you know they've exited. It's ugly, but should work
AttributeError: 'xbmcgui.Window' object has no attribute '__del__'


Presume that's a private method.

I really don't like the idea of running a whole service just to get a plugin to exit back to the underlying window (and note that the script SHOULD be the underlying windo in the stack - it's wierd pluging drop back to the programs menu by default.....
Sorry, no help w/out a *full debug log*
You can exit the addon and go back to the previous screen using:

xbmc.executebuiltin("Action(Back,%s)" % xbmcgui.getCurrentWindowId())


xbmc.executebuiltin("Action(ParentDir,%s)" % xbmcgui.getCurrentWindowId())
Thread Rating:
  • 0 Vote(s) - 0 Average

Logout Mark Read Team Forum Stats Members Help
Exiting Plugin00