Kodi Community Forum

Full Version: script.skinshortcuts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(2017-05-09, 11:32)Tgxcorporation Wrote: [ -> ]Hi!

Just a quick question.

Is it possible to use the "template.xml" functionality to create multiple widgets for each main menu item or it can be used only for one widget per main menu item?

I'm currently using my own implementation for multiple widgets and i'd like to test templates especially to overcome the issue with reloading widgets every time i switch to a new main menu item.

Maybe somebody has already tried and could show me the way ;-)

Thanks

Tgx


Take a look at Bob's igConq, it has support for multiple widgets per menu item. Aside from that, there's more to learn from it Smile
(2017-05-09, 17:47)Jeroen Wrote: [ -> ]Take a look at Bob's igConq, it has support for multiple widgets per menu item. Aside from that, there's more to learn from it Smile

Thanks, i'm having a look at it!

Tgx
The igConq implementation is probably way too complex for most skins - it allows an unlimited number of widgets per menu item rather than a fixed number of, say, two or three. If you just want a fixed number there are plenty of skins which have an implementation you can take a look at, but the basic idea is

(1) Provide GUI 312 in your management dialog, then send clicks to it with a unique identifier for each additional widget (so you could use 312 directly for the first widget, an identifier of '2' for the second, '3' for the third and so on. [Docs]

(2) Provide an 'other' template for each widget - one template for the first, one for the second and so on.

The condition for the first would be based on whether there's a widgetPath property, the second 'widgetpath.2' and so on. And for the first you'd set your properties to the normal widget properties the script returns, for the second you're pulling out the same properties with the addition of '.2' and so on.
Guilouz Wrote:Hi Bob,

I don't really understand how is working templates. I want to avoid widgets reloading and I see it's the solution.

This is my Personalized widgets : [redacted-in-case-you-don't-want-it-publically-shared-and-thats-why-you-PM'd-me]

How to "convert" this to use them as templates ?

Thanks for your reply.

Hi Goilouz. Hope you don't mind me responding here - I do my absolute upmost not to do 'support' via PM Smile

It's not necessarily easy to convert what you have to templates, purely because the different elements of Skin Shortcuts are designed to work with each other. So, when using templates for widgets they work best with the Skin Shortcuts widgets methods - You may well be using them already, but just in case I'm going to go from the absolute basics here. So, the entire process, assuming you're not already managing the widgets with Skin Shortcuts, would be something like...

(1) Add a couple of new controls to the management dialog. GUI 312 to let the user select a widget, and a second with an ID of your choice (which doesn't clash with any of Skin Shortcuts own GUI controls) to choose a layout for the widgets

(2) Now, in the overrides.xml, you need to tell the script what layouts your support. Something like the following:

Code:
<property property="widgetLayout" label="Categories Big">WidgetListCategoriesBig</property>
<property property="widgetLayout" label="Categories Small">WidgetListCategoriesSmall</property>
<property property="widgetLayout" label="List Poster">WidgetListPoster</property>

Keep going until you have one for each layout you support. Note the value that will be set is the name of your include for that layout - that will make things easier when writing the template. (You could potentially use the template to decide which layout to use based on content, for example, but this is the easiest way and a good place to start!)

Edit: Actually, you might already be doing something like this with your WidgetStyles property - if so, then obviously just use that instead of this widgetLayout, though you'd need to tell the template what include to use for whatever values you have for the WidgetStyles property...

Now, still in the overrides, tell Skin Shortcuts to use the second button you added in step (1) to actually set the 'widgetLayout' property:

Code:
<propertySettings property="widgetLayout" buttonID="[id-you-chose-in-(1)]" />

More details on properties - https://github.com/BigNoid/script.skinsh...properties

(3) The template. Because you already use includes and params, this should actually be quite easy. You're going to want an 'other' template, and build it when the widgetPath property is set. We'll pull out the various widget properties that the script sets, and the widgetLayout property we've added (as well as give that a fallback). A simplistic template for a single widget only - which obviously hasn't been tested by me in any way, and doesn't include things such as scrollbars or anything else beyond the actual include, would be…

Code:
    <other include="widget">
        <!-- Only build if the widgetPath property has a value -->
        <condition tag="property" attribute="name|widgetPath" />

        <!-- Pull out Skin Shortcuts widget properties -->
        <property name="name" tag="property" attribute="name|widgetName" />
        <property name="path" tag="property" attribute="name|widgetPath" />
        <property name="target" tag="property" attribute="name|widgetTarget" />

        <!-- Pull out the widgetLayout property, and give it a value if none is specified -->
        <!-- Note, there are other ways to give it a default value - doing it here may not be the best way -->
        <property name="layout" tag="property" attribute="name|widgetLayout" />
        <property name="layout">WidgetListPoster</property>

        <!-- We also pull out the ID of the main menu so we can ensure each list has a unique ID -->
        <property name="id" tag="mainmenuid" />

        <controls>
            <!-- Every one will be in it's own grouplist, so let's define it and give it a unique ID -->
            <control type="grouplist" id="2200$SKINSHORTCUTS[id]">
                <!-- Current common include -->
                <include>WidgetGroupListCommon</include>
                <!-- Skin Shortcuts-managed visibility -->
                <skinshortcuts>visibility</skinshortcuts>
                <!-- Use the value of 'widgetLayout' as the name of the include we're using -->
                <include content="$SKINSHORTCUTS[layout]">
                    <!-- Pass the Skin Shortcuts widget parameters to the include -->
                    <param name="content_path" value="$SKINSHORTCUTS[path]"/>
                    <param name="widget_header" value="$SKINSHORTCUTS[name]"/>
                    <param name="widget_target" value="$SKINSHORTCUTS[target]"/>
                    <!-- Not sure what this one does exactly, but I'm sure you know what to do with it -->
                    <param name="list_id" value="22100"/>
                    <!-- Skin Shortcuts can set the visibility, so the following isn't used any more -->
                    <!-- <param name="visible" value="String.Contains(Container(9000).ListItem.Property(WidgetStyle1),Posters) | String.IsEmpty(Container(9000).ListItem.Property(WidgetStyle1))"/> -->
                </include>
            </control>
        </controls>

    </other>

And you should have something that - with a bit of time taken to understand, debug and tweak - should work as your first widget.
Thanks for your replay, not easy...

I already use GUI 312 for user can select default widgets (preconfigured widgets) or personalized widgets (empty widgets that users must set) :

Code:
<control type="button" id="312">
                    <include>DefaultSettingButton</include>
                    <label></label>
                    <label2></label2>
                    <visible>false</visible>
                </control>
                <control type="button" id="10005">
                    <include>DefaultSettingButton</include>
                    <label>$LOCALIZE[40136]</label>
                    <label2>$VAR[Label_SkinSetting_Widget]</label2>
                    <onclick>SetProperty(WidgetVisibility,True,home)</onclick>
                    <onclick>SendClick(312)</onclick>
                    <visible>String.IsEqual(Window.Property(groupname),mainmenu)</visible>
                    <visible>!String.IsEqual(Container(211).ListItem.Property(defaultID),libreelec)</visible>
                </control>

Like this :

Image

With widgets grouping :

Code:
<!-- Default Widgets -->
    <widgetdefault labelID="disc">DiscWidget</widgetdefault>
    <widgetdefault labelID="movies">MoviesWidget</widgetdefault>
    <widgetdefault labelID="tvshows">TVShowsWidget</widgetdefault>
    <widgetdefault labelID="music">MusicWidget</widgetdefault>
    <widgetdefault labelID="musicvideos">MusicVideosWidget</widgetdefault>
    <widgetdefault labelID="livetv">LiveTVWidget</widgetdefault>
    <widgetdefault labelID="radio">RadioWidget</widgetdefault>
    <widgetdefault labelID="games">GamesWidget</widgetdefault>
    <widgetdefault labelID="addons">AddonsWidget</widgetdefault>
    <widgetdefault labelID="pictures">PicturesWidget</widgetdefault>
    <widgetdefault labelID="video">VideoWidget</widgetdefault>
    <widgetdefault labelID="favorites">FavoritesWidget</widgetdefault>
    <widgetdefault labelID="weather">WeatherWidget</widgetdefault>
    
    <!-- Additionnal Widgets -->
    <widget label="427" icon="icons/sidemenu/disc.png">DiscWidget</widget>
    <widget label="342" icon="icons/sidemenu/movies.png">MoviesWidget</widget>
    <widget label="20343" icon="icons/sidemenu/tv.png">TVShowsWidget</widget>
    <widget label="2" icon="icons/sidemenu/music.png" >MusicWidget</widget>
    <widget label="20389" icon="icons/sidemenu/musicvideos.png">MusicVideosWidget</widget>
    <widget label="19020" icon="icons/sidemenu/livetv.png">LiveTVWidget</widget>
    <widget label="19021" icon="icons/sidemenu/radio.png">RadioWidget</widget>
    <widget label="15016" icon="icons/sidemenu/games.png">GamesWidget</widget>
    <widget label="24001" icon="icons/sidemenu/addons.png">AddonsWidget</widget>
    <widget label="1" icon="icons/sidemenu/pictures.png">PicturesWidget</widget>
    <widget label="3" icon="icons/sidemenu/videos.png">VideoWidget</widget>
    <widget label="10134" icon="icons/sidemenu/favourites.png">FavoritesWidget</widget>
    <widget label="8" icon="icons/sidemenu/weather.png">WeatherWidget</widget>
    <widget label="40134" icon="DefaultAddonLookAndFeel.png">PersonalWidget</widget>

<widget-groupings>
        <node label="40127" condition="!String.IsEmpty(Window(home).Property(WidgetVisibility))">
            <shortcut label="427" icon="icons/sidemenu/disc.png" widget="DiscWidget" condition="System.HasMediaDVD">DiscWidget</shortcut>
            <shortcut label="342" icon="icons/sidemenu/movies.png" widget="MoviesWidget">MoviesWidget</shortcut>
            <shortcut label="20343" icon="icons/sidemenu/tv.png" widget="TVShowsWidget">TVShowsWidget</shortcut>
            <shortcut label="2" icon="icons/sidemenu/music.png" widget="MusicWidget">MusicWidget</shortcut>
            <shortcut label="20389" icon="icons/sidemenu/musicvideos.png" widget="MusicVideosWidget">MusicVideosWidget</shortcut>
            <shortcut label="19020" icon="icons/sidemenu/livetv.png" widget="LiveTVWidget">LiveTVWidget</shortcut>
            <shortcut label="19021" icon="icons/sidemenu/radio.png" widget="RadioWidget">RadioWidget</shortcut>
            <shortcut label="15016" icon="icons/sidemenu/games.png" widget="GamesWidget" condition="System.GetBool(gamesgeneral.enable)">GamesWidget</shortcut>
            <shortcut label="24001" icon="icons/sidemenu/addons.png" widget="AddonsWidget">AddonsWidget</shortcut>
            <shortcut label="1" icon="icons/sidemenu/pictures.png" widget="PicturesWidget">PicturesWidget</shortcut>
            <shortcut label="3" icon="icons/sidemenu/videos.png" widget="VideoWidget">VideoWidget</shortcut>
            <shortcut label="10134" icon="icons/sidemenu/favourites.png" widget="FavoritesWidget">FavoritesWidget</shortcut>
            <shortcut label="8" icon="icons/sidemenu/weather.png" widget="WeatherWidget">WeatherWidget</shortcut>
        </node>
        <node label="40134" condition="!String.IsEmpty(Window(home).Property(WidgetVisibility))">
            <shortcut label="40166" icon="DefaultAddonLookAndFeel.png" widget="PersonalWidget">PersonalWidget</shortcut>
            <shortcut label="40167" icon="DefaultAddonLookAndFeel.png" widget="PersonalWidget2">PersonalWidget2</shortcut>
            <shortcut label="40168" icon="DefaultAddonLookAndFeel.png" widget="PersonalWidget3">PersonalWidget3</shortcut>
            <shortcut label="40169" icon="DefaultAddonLookAndFeel.png" widget="PersonalWidget4">PersonalWidget4</shortcut>
            <shortcut label="40121" icon="DefaultAddonLookAndFeel.png" widget="PersonalWidget5">PersonalWidget5</shortcut>
        </node>  
</widget-groupings>

So do I need to use templates for my default widgets too ?
(2017-05-09, 23:41)Guilouz Wrote: [ -> ]Thanks for your replay, not easy...

I think its fair to say that templates generally are very difficult, but once you get your head around how they work...

(2017-05-09, 23:41)Guilouz Wrote: [ -> ]So do I need to use templates for my default widgets too ?

Skinners choice Smile But I don't believe your default widgets would have a 'widgetPath' property, so the sample template I provided wouldn't build for them anyway...
When using python, is there a way to evaluate conditions using multiple values? Like:

PHP Code:
<include condition="$PYTHON['True' if WidgetLayout == 'value1' | 'value2' else 'False']" content="includename"

Tried using ^ too, but in both cases the building fails.
(2017-05-09, 19:09)BobCratchett Wrote: [ -> ]The igConq implementation is probably way too complex for most skins - it allows an unlimited number of widgets per menu item rather than a fixed number of, say, two or three. If you just want a fixed number there are plenty of skins which have an implementation you can take a look at, but the basic idea is

I'm having a look at your skin. The widget implementation is fairly complex. I think i've understood the way it works.
I see you can switch between widgets with the "widgetControl" template because you are displaying a single widget one at a time.
Instead i'd like to display all the widgets together stacked on top of each other in a grouplist.
Is it possible with templates?

Thanks

Tgx
(2017-05-10, 15:24)Tgxcorporation Wrote: [ -> ]
(2017-05-09, 19:09)BobCratchett Wrote: [ -> ]The igConq implementation is probably way too complex for most skins - it allows an unlimited number of widgets per menu item rather than a fixed number of, say, two or three. If you just want a fixed number there are plenty of skins which have an implementation you can take a look at, but the basic idea is

I'm having a look at your skin. The widget implementation is fairly complex. I think i've understood the way it works.
I see you can switch between widgets with the "widgetControl" template because you are displaying a single widget one at a time.
Instead i'd like to display all the widgets together stacked on top of each other in a grouplist.
Is it possible with templates?

Thanks

Tgx

I know this isn't directed at me, and I sure wouldn't call myself the expert, but I think you can

I am not using multiple widgets per menu item but I am using all main menu widgets at once. If you stick your template in a grouplist and make use of parameters the navigation between the widgets is all taken care of quite easily by the grouplist.

Simplified snippet:
PHP Code:
<control type="grouplist" id="9100">
    <
itemgap>0</itemgap>
    <
orientation>vertical</orientation>
    <
onup>noop</onup>
    <
ondown>noop</ondown>
    <
scrolltime tween="cubic" easing="out">500</scrolltime>
    <include 
content="skinshortcuts-template-widget_Regular">
    </include>
</
control

As I wanted all the widgets to show at once regardless of which main menu is selected I stripped out the <skinshortcuts>visibility</skinshortcuts> to achieve this (well it was a little more complicated than that..) but I don't see why it wouldn't be possible to do this per menu item.

Bob will surely give you a better answer than me though Wink
(2017-05-10, 13:38)Jeroen Wrote: [ -> ]When using python, is there a way to evaluate conditions using multiple values? Like:

PHP Code:
<include condition="$PYTHON['True' if WidgetLayout == 'value1' | 'value2' else 'False']" content="includename"

Tried using ^ too, but in both cases the building fails.

Never tried, but possibly:

Code:
'True' if WidgetLayout in ['value1', 'value2'] else 'False'

Guaranteed to work would be the long-hand:

Code:
'True' if WidgetLayout == 'value1' else 'True' if WidgetLayout == 'value2' else 'False'

(2017-05-10, 16:56)Jeroen Wrote: [ -> ]Bob will surely give you a better answer than me though Wink

Nope - not only has Bob never tried it, but your answer seems sounds Smile
(2017-05-10, 18:33)BobCratchett Wrote: [ -> ]Nope - not only has Bob never tried it, but your answer seems sounds Smile

(2017-05-10, 16:56)Jeroen Wrote: [ -> ]If you stick your template in a grouplist and make use of parameters the navigation between the widgets is all taken care of quite easily by the grouplist.

Simplified snippet:
PHP Code:
<control type="grouplist" id="9100">
    <
itemgap>0</itemgap>
    <
orientation>vertical</orientation>
    <
onup>noop</onup>
    <
ondown>noop</ondown>
    <
scrolltime tween="cubic" easing="out">500</scrolltime>
    <include 
content="skinshortcuts-template-widget_Regular">
    </include>
</
control

I'm going to try it on my Andromeda skin soon.

Thanks to everybody. Smile

Tgx
(2017-05-10, 18:33)BobCratchett Wrote: [ -> ]Never tried, but possibly:

Code:
'True' if WidgetLayout in ['value1', 'value2'] else 'False'

Guaranteed to work would be the long-hand:

Code:
'True' if WidgetLayout == 'value1' else 'True' if WidgetLayout == 'value2' else 'False'

Could only get the longhand to work, but that's totally fine, this will save me yet some more blocks of code Wink Cheers
(2017-05-10, 20:42)Jeroen Wrote: [ -> ]
(2017-05-10, 18:33)BobCratchett Wrote: [ -> ]Never tried, but possibly:

Code:
'True' if WidgetLayout in ['value1', 'value2'] else 'False'

Guaranteed to work would be the long-hand:

Code:
'True' if WidgetLayout == 'value1' else 'True' if WidgetLayout == 'value2' else 'False'

Could only get the longhand to work, but that's totally fine, this will save me yet some more blocks of code Wink Cheers

As much as I love the fact that templates are - afaik - the first chance for skinners to use a little bit of Python, its worth saying you could probably do what you want without Python, too:

Code:
<property name="layout" tag="property" attribute="name|WidgetLayout" value="value1">True</property>
<property name="layout" tag="property" attribute="name|WidgetLayout" value="value2">True</property>
<property name="layout">False</property>

The real advantage to using Python would be if you didn't always want the value to be True or False based on the same conditions every time....
(2017-05-10, 21:02)BobCratchett Wrote: [ -> ]
(2017-05-10, 20:42)Jeroen Wrote: [ -> ]
(2017-05-10, 18:33)BobCratchett Wrote: [ -> ]Never tried, but possibly:

Code:
'True' if WidgetLayout in ['value1', 'value2'] else 'False'

Guaranteed to work would be the long-hand:

Code:
'True' if WidgetLayout == 'value1' else 'True' if WidgetLayout == 'value2' else 'False'

Could only get the longhand to work, but that's totally fine, this will save me yet some more blocks of code Wink Cheers

As much as I love the fact that templates are - afaik - the first chance for skinners to use a little bit of Python, its worth saying you could probably do what you want without Python, too:

Code:
<property name="layout" tag="property" attribute="name|WidgetLayout" value="value1">True</property>
<property name="layout" tag="property" attribute="name|WidgetLayout" value="value2">True</property>
<property name="layout">False</property>

The real advantage to using Python would be if you didn't always want the value to be True or False based on the same conditions every time....

Yup, that's a way I have been using too. I just saw an opportunity to take a different approach where using python seemed to come in handy. It didn't work out eventually (not because of the python bit), but it is knowledge gained that could pay out later Wink

Apart from that, it's nice to try new things. I am planning to see if I can use Python to make the process of determining which widget uses which type of art smarter Smile

And being able to use basic calculations is a blessing I wish we could enjoy everywhere in Kodi Big Grin
(2017-05-10, 20:42)Jeroen Wrote: [ -> ]Apart from that, it's nice to try new things. I am planning to see if I can use Python to make the process of determining which widget uses which type of art smarter Smile

And being able to use basic calculations is a blessing I wish we could enjoy everywhere in Kodi Big Grin


I actually just finished a add-on script for a widget I think I am going to call the uniwidget. With the script and a lot of code... You can set the content to whatever you like and it automagiclly decides based on the content what art work to show... It even shows mix content ... So u can see poster thumbs and icons all in the same layout.

It will be apart of my skin once I get to the point of going public.