Several issues with DialogSlider.xml
#1
Hello folks,

for an addon (home automation/smart home) I need a slider control where I can set a temperature value of a thermostat. So I decided to use the DialogSlider.xml for this because it's an default window (sliderdialog, 10145), but running in several issues.

Code:
class Slider():

    device = None
    DialogSlider = xbmcgui.Window(10145)

    def __init__(self):
        self.DialogSlider.show()
        try:
            self._header = self.DialogSlider.getControl(10)
            self._value = self.DialogSlider.getControl(12)
            self._slider = self.DialogSlider.getControl(11)
        except RuntimeError:
            pass

    def update(self):
        self._header.setLabel(device.name)
        self._value.setLabel(device.temp[0])
        self._slider.setPercent(device.temp[1])

    def onClick(self, cid):
        t.writeLog('clicked on ID %s' % (cid)) # t.writeLog is a special func to write in kodi.log

    def onControl(self, cid):
        t.writeLog('clicked on ID %s' % (cid))

    def onInit(self):
        t.writeLog('Window Init')

    def onAction(self, action):
        t.writeLog(action.getId)

slider = Slider()
slider.device = device   # thermostat object with formatted properties
slider.update()

Issues:
  • without self.DialogSlider().show on __init__() I get a runtime error (control(id) doesn't exists) and I couldn't set the values of the controls of coarse.
  • with self.DialogSlider().show on __init()__ I get an 'empty' Dialog without values. The update() doesn't refresh/update the Dialog window. On next call all controls are filled with correct values.
  • None of the event handler (onClick, onControl, onInit, onAction) seems to be called.

Any hints would be very appreciate.
Reply
#2
I'm not sure that you are using the Slider dialog correctly. There's xbmcgui.ControlSlider class that exposes the Slider dialog to Python.
Reply
#3
control id 10 is a label control (heading of the dialog window)
control id 11 is the slider itself and could be controlled by getPercent/setPercent
control id 12 is a label control (could use for additional infos)

All controls are defined properly in the DialogSlider.xml of the skin and could accessed by xbmcgui.Window(windowId).
Reply
#4
Bump. Any hints?
Reply

Logout Mark Read Team Forum Stats Members Help
Several issues with DialogSlider.xml0