Exiting Plugin
#16
I think this will do it:

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

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

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

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

    if actionName is not None:
        xbmc.executebuiltin("ActivateWindow(Programs,plugin://script.xsqueeze")

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

..adn this give me:

Code:
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??
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#18
Damn, looks like onAction is coded specifically so it can't be overridden.
Maybe you can catch when the window is destroyed? Try this:
Code:
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
Reply
#19
AttributeError: 'xbmcgui.Window' object has no attribute '__del__'

Sad

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.....
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#20
You can exit the addon and go back to the previous screen using:

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

or

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

Logout Mark Read Team Forum Stats Members Help
Exiting Plugin0