passing integer to skin
#1
Can I pass a numeric info to skin from python?

I need to fill a progress control, but have no clue how to go about it.

sorry for the dumb question, but I'v bee searching for a day with no results.
Image Image
Did I Help? Add to my reputation
Reply
#2
you can set window / listitem properties. that´s not enough?
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#3
i tried setting window property but it's a string and doesn't work with progress control

listitem i haven't tried but then i'd have to create a list which is more than i need

i need to fill a property like for example System.BatteryLevel, which works with progress controls.

edit: in fact I need it to show a battery level for an external device
Image Image
Did I Help? Add to my reputation
Reply
#4
Here's how I I fill the progress control in an add-on with which I help (X-NEWA). In the skin file I have the progress bar:

Code:
<control type="progress" id="237">
    <description>Free Space Bar</description>
    <posx>0</posx>
    <posy>40</posy>
    <width>250</width>
    <height>25</height>
    <info>-</info>
</control>

When the script itself is initialized, I grab the progress bar and give it a name:
Code:
self.spacePercent = self.getControl(237)

And later in the code I actually set the percentage of the progress bar. Note that it isn't an integer, it's a float. At least I'm pretty sure it's a float. Dividing two integers gives you a float, right?

Code:
self.spacePercent.setPercent(100*lUsed/lTotal)

Hopefully this will get you headed in the right direction.
Reply
#5
(2014-12-16, 02:46)pkscout Wrote: Here's how I I fill the progress control in an add-on with which I help (X-NEWA). In the skin file I have the progress bar:

Code:
<control type="progress" id="237">
    <description>Free Space Bar</description>
    <posx>0</posx>
    <posy>40</posy>
    <width>250</width>
    <height>25</height>
    <info>-</info>
</control>

When the script itself is initialized, I grab the progress bar and give it a name:
Code:
self.spacePercent = self.getControl(237)

And later in the code I actually set the percentage of the progress bar. Note that it isn't an integer, it's a float. At least I'm pretty sure it's a float. Dividing two integers gives you a float, right?

Code:
self.spacePercent.setPercent(100*lUsed/lTotal)

Hopefully this will get you headed in the right direction.

it´s an int. (in python int / int = int)
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#6
I beieve getting the control and setting its "info" is the way to go, but

I have no clue how to go about it

1) the addon if no args are added calls a WindowXML
2) in this window I have progress control (created by the skin with id="200")
3) i'd like this progress control to get it's value from the addon whichgets the value from the net

I have the value and I have the XMLskinfile

what's next?
Code:
class thermopage:
    def __init__(self):
        self.parseargv()
        if self.SETTEMP:
            self.askfortemperature()
        elif self.AWAY:
            self.setaway()
        elif self.NOFREEZE:
            self.setnofreeze()
        elif self.TURNON:
            self.setmax()
        elif self.TURNOFF:
            self.setoff()
        elif self.PROGRAM:
            self.setprogram()
        else:
            _WINDOW.doModal()

        # UPDATE VALUES

        temp = str(devList.temperature)
        xbmcgui.Window(10000).setProperty('netatmo_HomeTemperature', temp)
        settemp = str(float(devList.setpoint_temp))
        xbmcgui.Window(10000).setProperty('netatmo_HomeSetTemperature', settemp)
        setmode = str(devList.setpoint_mode)
        xbmcgui.Window(10000).setProperty('netatmo_HomeSetMode', setmode)
        relaycommand = unicode(devList.thermrelaycmd)
        xbmcgui.Window(10000).setProperty('netatmo_RelayCommand', relaycommand)
        module_name = str(devList.modulename)
        xbmcgui.Window(10000).setProperty('netatmo_ModuleName', module_name)
        device_name = str(devList.devicename)
        xbmcgui.Window(10000).setProperty('netatmo_LocationName', device_name)

        respdev = str(devList.respdev)
        xbmcgui.Window(10000).setProperty('dev', respdev)
        respter = str(devList.respthermo)
        xbmcgui.Window(10000).setProperty('ter', respter)

        if setmode == 'manual':
            manual_end = str(devList.manual_endpoint)
            manual_end = lnetatmo.toTimeString(manual_end)

            xbmcgui.Window(10000).setProperty('ManualEnd', manual_end)

i tried calling the .getControl after _WINDOW.doModal()

i tried self.getControl -_WINDOW.getControl

Sad

oh I almost forgot: Thank You so much for helping.
Image Image
Did I Help? Add to my reputation
Reply
#7
I could help if you post the complete code on GitHub. I don´t like dealing with snippets Smile
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#8
(2014-12-17, 00:18)phil65 Wrote: I could help if you post the complete code on GitHub. I don´t like dealing with snippets Smile

you're right!

i forgot to add the location!!

https://github.com/fastcolors/service.ne...thermostat

and thanks a lot
Image Image
Did I Help? Add to my reputation
Reply
#9
first you should create your own WindowXML class.

http://kodi.wiki/view/WindowXML --> 2.3

and use that one for your new window / dialog.

you can put self.getControl(200).setPercent(xx) in onInit() then.
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#10
(2014-12-17, 01:34)phil65 Wrote: first you should create your own WindowXML class.

http://kodi.wiki/view/WindowXML --> 2.3

and use that one for your new window / dialog.

you can put self.getControl(200).setPercent(xx) in onInit() then.

thank you will try.
I thought just calling the window would be enough Sad
Image Image
Did I Help? Add to my reputation
Reply
#11
it is possible to do it without a new WindowXML class, but I would suggest to directly learn the proper way to implement this. Smile

Way two is:

window_id = xbmcgui.getCurrentWindowId()
xbmcgui.Window(window_id).getControl(200).setPercent(xx)
(or use a static WindowID, depends on usecase)
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#12
hooorayyyyyyy thank you so much!

(2014-12-17, 02:00)phil65 Wrote: it is possible to do it without a new WindowXML class, but I would suggest to directly learn the proper way to implement this. Smile

Way two is:

window_id = xbmcgui.getCurrentWindowId()
xbmcgui.Window(window_id).getControl(200).setPercent(xx)
(or use a static WindowID, depends on usecase)

no you're right I must learn the proper ways.
I tried building a Window class and it worked like a charm.

I know you got other stuff going on, but if you see that I'm doing horrible things in that script please kick my butt about them. I'd love to learn me some python.
Image Image
Did I Help? Add to my reputation
Reply

Logout Mark Read Team Forum Stats Members Help
passing integer to skin0