Add control problem
#1
Hi guys

I need some basic help with my code. I have stored a list of buttons in the arrays and I'm trying to add the buttons in the skin windows, but I have got an error: TypeError: Non api type passed to "addControls" in place of the expected type "p.XBMCAddon::xbmcgui::Control."


Here is the code:

Code:
program_title = '[B]' + title + '[/B]'

if self.programs == False:
    program_controls = xbmcgui.ControlButton(
        int(position_start),
        int(position_top),
        int(program_width),
        int(program_height),
        program_title,
        focusTexture = self.path + self.button_focus,
        noFocusTexture = self.path + self.button_nofocus,
        textColor ='0xFFFFFFFF',
        focusedColor ='0xFF000000'
    )
    self.add_programs.append(ProgramControls(program_controls, program))


if self.programs == False:
    self.addControls(self.add_programs)
    self.programs = True


Here is the output of the buttons:

Code:
17:35:39 T:2120  NOTICE: [<test.ProgramControls object at 0x105DF910>, <test.ProgramControls object at 0x105DF970>, <test.ProgramControls object at 0x105DF990>, <test.ProgramControls object at 0x105DF9B0>, <test.ProgramControls object at 0x105DF9D0>, <test.ProgramControls object at 0x105DF9F0>, <test.ProgramControls object at 0x105DFA10>, <test.ProgramControls object at 0x105DFA30>, <test.ProgramControls object at 0x105DFA50>, <test.ProgramControls object at 0x105DFA70>, <test.ProgramControls object at 0x105DFA90>, <test.ProgramControls object at 0x105DFAB0>, <test.ProgramControls object at 0x105DFAD0>, <test.ProgramControls object at 0x105DFAF0>, <test.ProgramControls object at 0x105DFB10>, <test.ProgramControls object at 0x105DFB30>, <test.ProgramControls object at 0x105DFB50>, <test.ProgramControls object at 0x105DFB70>, <test.ProgramControls object at 0x105DFB90>, <test.ProgramControls object at 0x105DF930>, <test.ProgramControls object at 0x105DFBB0>, <test.ProgramControls object at 0x105DFBD0>, <test.ProgramControls object at 0x105DFC30>, <test.ProgramControls object at 0x105DFC50>, <test.ProgramControls object at 0x105DFC70>, <test.ProgramControls object at 0x105DFC90>, <test.ProgramControls object at 0x105DFCB0>, <test.ProgramControls object at 0x105DFCD0>, <test.ProgramControls object at 0x105DFCF0>, <test.ProgramControls object at 0x105DFD10>, <test.ProgramControls object at 0x105DFD30>, <test.ProgramControls object at 0x105DFD50>, <test.ProgramControls object at 0x105DFD70>, <test.ProgramControls object at 0x105DFD90>, <test.ProgramControls object at 0x105DFDB0>, <test.ProgramControls object at 0x105DFDD0>, <test.ProgramControls object at 0x105DFDF0>, <test.ProgramControls object at 0x105DFE10>, <test.ProgramControls object at 0x105DFE30>, <test.ProgramControls object at 0x105DFE50>, <test.ProgramControls object at 0x105DFE70>, <test.ProgramControls object at 0x105DFE90>, <test.ProgramControls object at 0x105DFEB0>, <test.ProgramControls object at 0x105DFED0>, <test.ProgramControls object at 0x105DFEF0>, <test.ProgramControls object at 0x105DFF10>, <test.ProgramControls object at 0x105DFF30>, <test.ProgramControls object at 0x105DFF50>, <test.ProgramControls object at 0x105DFF70>, <test.ProgramControls object at 0x105DFF90>, <test.ProgramControls object at 0x105DFFB0>, <test.ProgramControls object at 0x105DFFD0>, <test.ProgramControls object at 0x105DFFF0>, <test.ProgramControls object at 0x105DFC10>, <test.ProgramControls object at 0x105DF8D0>, <test.ProgramControls object at 0x105DF950>, <test.ProgramControls object at 0x105DFBF0>, <test.ProgramControls object at 0x0D26AA10>, <test.ProgramControls object at 0x0D26AA70>, <test.ProgramControls object at 0x0D26A550>, <test.ProgramControls object at 0x0D26A8F0>, <test.ProgramControls object at 0x0D26ADD0>, <test.ProgramControls object at 0x0D26A650>, <test.ProgramControls object at 0x0D26AFF0>, <test.ProgramControls object at 0x0D26A4D0>, <test.ProgramControls object at 0x0D26AE90>, <test.ProgramControls object at 0x0D26A890>, <test.ProgramControls object at 0x0D26AD30>, <test.ProgramControls object at 0x0D26A6D0>]


I have got no idea what I'm supposed to do.

Can you please help me how I can add the buttons control in the skin window?
Reply
#2
If I'm reading your code right, you're only adding one control at a time (not within a loop), so no need to have self.add_programs, just set it to the new control. Though I've no idea what you're doing with self.programs in this...
Reply
#3
@BoboCratchett thank you very much for your help, you are almost correct. I've created a empty list to appending the controls to a list to add the controls when I pressed on the down arrow button of the keyboard. I'm trying to appending another controls to a list to add the controls when I press on the down arrow button again but i get the error.

Do you know how I can appending the controls to a list in each time when I press on the down arrow button of the keyboard to allow me to add the controls in each time?

If that is possible, please let me know.
Reply
#4
(2015-01-01, 20:40)Pr0ph3cyTiger Wrote: @BoboCratchett thank you very much for your help, you are almost correct. I've created a empty list to appending the controls to a list to add the controls when I pressed on the down arrow button of the keyboard. I'm trying to appending another controls to a list to add the controls when I press on the down arrow button again but i get the error.

Do you know how I can appending the controls to a list in each time when I press on the down arrow button of the keyboard to allow me to add the controls in each time?

If that is possible, please let me know.

You are adding a list of controls, not the individual controls within the list. You must add the individual items from the list, not the whole list at the same time.
Reply

Logout Mark Read Team Forum Stats Members Help
Add control problem0