script.skinshortcuts
#1
Hi all,

I hope this is the right thread to post this but you guys look like skin.shortcuts experts. I am currently developing a plugin which requires me to choose a plugin or a favorite and save it in my settings file. I would love to use the skin.shortcuts plugin because it gives one menu item which I can use to point to favorites and save the url in my settings file, a video or addon and save that, media files, actions etc all in one shortcuts window. This is the same menu dialog that is used in the AEON NOX theme when adding custom items to the menu. I can launch the plugin and dialog as by executing the following in my script:

Code:
xbmc.executebuiltin('XBMC.RunScript(script.skinshortcuts,type=shortcuts&custom=True&skinLabel=Alarm)')

but for some reason, whenever I select a favorite, the path to the favorite is not returned to my addon configuration screen in order to save the path. I thought the would be possible with the just select of the skin.shortcuts but it does not work. I even tried capturing the selection by using
Code:
path = xbmc.executebuiltin('Skin.String(Alarm)')
but alas, it still does nothing.

Can anyone point me in the right direction as to how to return the selected item path from skin.shortcuts back to my addons configuration screen so that I can save it in the settings file?

Tour help and time is much appreciated.

Thanks
J
Reply
#2
Have another read of the Just Select documentation - you need to specify all the properties you want returned to the skin, and which skin string you want them saved in. In your example Skin Shortcuts is only setting the skin string 'Alarm' with the label of the shortcut that is selected. For the action you want skinAction=[skin string you want the action saved to]...

(And then to grab it into a plugin, you'd want xbmc.getInfoLabel("Skin.String([skin string])") - there's no way for the script to return a value directly to another script...)
Reply
#3
(2015-12-08, 16:34)BobCratchett Wrote: Have another read of the Just Select documentation - you need to specify all the properties you want returned to the skin, and which skin string you want them saved in. In your example Skin Shortcuts is only setting the skin string 'Alarm' with the label of the shortcut that is selected. For the action you want skinAction=[skin string you want the action saved to]...

(And then to grab it into a plugin, you'd want xbmc.getInfoLabel("Skin.String([skin string])") - there's no way for the script to return a value directly to another script...)

Thank you @BobCratchett,

I have changed my code accordingly like this:

Code:
def chooseVideoAddonStream(number):
    path = "str"
    xbmc.log("chooseStream method reached")
    xbmc.executebuiltin('XBMC.RunScript(script.skinshortcuts,type=shortcuts&custom=True&skinLabel=Alarm&skinAction=AlarmAction)')
    path = xbmc.getInfoLabel("Skin.String([AlarmAction])")
    line1 = str(path)
    time = 5000 #in miliseconds

    xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__))

The only question is now how do I get the script to wait until the user selects an item from the shortcuts menu? in the code above you can see that I am fetching the skin string into a variable, however, the method executes and continues to execute before the user selects an item so in essence, the skin variable is not set to be grabbed in the first place. The notification pops up immediately with a blank body which is set to path so the variable is empty. Makes sense as the user has not chosen anythin yet.

Is there someway I can make the script wait until the user selected an item from the shortcuts menu, the value is set, and then grab it? sort of like a onDialogResult of sorts.

Thanks for the help, I really appreciate it.

Thanks
J
Reply
#4
A total hack would be something along the lines of:-

Code:
while xbmc.getCondVisibility("Window.IsVisible(DialogSelect.xml)") or xbmc.getCondVisibility("Window.IsVisible(ProgressDialog)"):
    if xbmc.Monitor().waitForAbort(1):
        break

The better solution would be to either pull Skin Shortcuts shortcut-selection functionality into your own script (most of the magic happens in library.py - though you'd need at least elements of datafunctions.py and nodefunctions.py.) Or extend the Just Select method to take a script id, and have Skin Shortcuts run the calling script - passing along the various selected properties - when the user has selected something.
Reply
#5
(2015-12-09, 10:54)BobCratchett Wrote: A total hack would be something along the lines of:-

Code:
while xbmc.getCondVisibility("Window.IsVisible(DialogSelect.xml)") or xbmc.getCondVisibility("Window.IsVisible(ProgressDialog)"):
    if xbmc.Monitor().waitForAbort(1):
        break

The better solution would be to either pull Skin Shortcuts shortcut-selection functionality into your own script (most of the magic happens in library.py - though you'd need at least elements of datafunctions.py and nodefunctions.py.) Or extend the Just Select method to take a script id, and have Skin Shortcuts run the calling script - passing along the various selected properties - when the user has selected something.

I do agree that it would be a better solution to try and strip that functionality from skin.shortcuts. Then my Addon will not be dependant on any addons either. I tried it before but I could not get it to work properly... I will give it another bash though and see if it works. Your information helped a lot due to your comments about library and the other two scripts. Thanks a lot! It is much appreciated
Reply
#6
Sadly, I havi hit another fluke.

I have integrated the shortcuts addon code into my addon. Basically exactly the same. I combined all the code from my addon and the shortcut addon. libraries, languages etc. In the end I ended up with 2 addon.xml files and 2 default.py files in the root. I renamed the default.py file from the shortcuts addon to shortcuts.py. I then combined the 2 addon.xml files. I now have an addon.xml file with multiple extension points and combined imports like this:

<requires>
<import addon="xbmc.python" version="2.19.0"/>
<import addon="script.module.simplejson" version="3.3.0"/>
<import addon="script.module.unidecode" version="0.4.14"/>
</requires>

<extension point="xbmc.service" library="default.py" start="startup"></extension>
<extension point="xbmc.python.library" library="shortcuts.py"></extension>

Notice that the extension point for the shortcuts.py (which use to be default.py) now has a library attribute of shortcuts.py.

in the shortcuts.py file, I basically changed the code where it sets the skin action to update my setting by changing this:

Code:
if self.ACTION is not None:
                    __addon__.setSetting("videoaddon%d" % 1,path)
                    xbmc.executebuiltin( "Skin.SetString(" + self.ACTION + "," + path + " )" )

to this:

Code:
if self.ACTION is not None:
                    __addon__.setSetting("videoaddon%d" % 1,path)
                    xbmc.executebuiltin( "Skin.SetString(" + self.ACTION + "," + path + " )" )

Now nothing else has changed, I am still calling the script from my settings file with the following:

RunScript(script.service.myalarm,type=shortcuts&amp;custom=True&amp;skinLabel=Alarm&amp;skinAction=AlarmAction)

In my opinion, this should call the shortcuts.py file as specified in the addon.xml and further work normally like the original script.skinshortcuts correct? The problem is, my service starts, I can see it in the log. I can configure, but when I need to choose a file, the window does not pop up and nothing happens. In the log I then see the following error:

Code:
13:47:39 T:5712   ERROR: CScriptInvocationManager::ExecuteAsync - Not executing non-existing script script.service.myalarm
13:47:59 T:10196   ERROR: Previous line repeats 10 times.
13:47:59 T:10196  NOTICE: Thread JobWorker start, auto delete: true
13:48:01 T:7240  NOTICE: Thread LanguageInvoker start, auto delete: false
13:48:01 T:7240  NOTICE: -->Python Interpreter Initialized<--
13:48:01 T:1396  NOTICE: Thread RSSReader start, auto delete: false
13:48:05 T:216  NOTICE: Thread BackgroundLoader start, auto delete: false
13:48:15 T:5712   ERROR: CPythonInvoker(13, C:\Users\xxxxx\AppData\Roaming\Kodi\addons\script.service.miloalarm\default.py): script didn't stop in 5 seconds - let's kill it

Am I completely missing anything here? I am fairly new to this so finding my way around is still a bit vague. Huh

Thanks for the help. It is much appreciated.

Thanks
J
Reply
#7
(We've moved away from skin development here - if a mod reads this, any chance of the last few posts being split off into the python development forum? If mods aren't able to to that, please don't be offended if I ask you to start a new thread over there if the conversation continues on!)

Yup, that sounds like it should work. Without seeing the actual code its very difficult to say why it isn't.

I'm not familiar with the 'Not executing non-existent script' error that you're getting, but that's the first place I'd look as it sounds like Kodi isn't running the Skin Shortcuts side of your script at all - especially double-checking that the new name for skin shortcuts default.py exactly matches the library= in the addon.xml file. Also, as you've presumably also imported Skin Shortcuts settings.xml, you'll now have a settings page for your add-on where you can enable debug logging (Skin Shortcuts won't write any debug logging without this option) - so if the script is getting run (as I say, from the log snippet I'm not sure it is) that might give some more insight.
Reply
#8
Split and moved for you Bob. Wink
Reply
#9
Thanks Hitcher Smile

@joachimpr Please do report back how you are getting on. Support within Skin Shortcuts for 3rd party scripts is something thats been at the back of my mind for a little while, so I'd love to take your experiences on board when considering future upgrades to the script Smile
Reply

Logout Mark Read Team Forum Stats Members Help
script.skinshortcuts0