AttributeError: 'xbmcgui.ControlButton' object has no attribute 'control
#1
Hi guys,

I have a problem with the button controls. When I'm adding the list of buttons and when I'm checking on the variable to check if it outside the piexel area then I want to use setVisble method to hide for each button.

When I try this:

Code:
def __init__(self):
    self.program_buttons = []
    self.channels_Index = 0
    self.programs_Index = 0


def MyChannels(self, *controlIds):

    #get the programs list
    cur = con.cursor()
    cur.execute('SELECT channel, title, start_date, stop_date FROM programs WHERE channel=? LIMIT 3', [channel])
    programList = list()
    programs = cur.fetchall()
    start_pos = 375    # indent for first program

    for ind, row in enumerate(programs):
        program = row[1].encode('ascii'), str(row[2]), str(row[3])
        title = row[1].encode('ascii')
        program_title = '[B]' + title + '[/B]'

        program_controls = xbmcgui.ControlButton(
            int(position_start),
            int(position_top),
            int(program_width),
            int(program_height),
            program_title,
            focusTexture = button_focus,
            noFocusTexture = button_nofocus,
            textColor = text_color,
        )
        self.program_buttons.append(program_controls)

        #hide the control if it greater than 724.5 in pixels
        if position_start > 1233:
            controls = [elem.control for elem in self.program_buttons]
            self.controls.setVisible(False)

        self.addControl(program_controls)


I will get an error: AttributeError: 'xbmcgui.ControlButton' object has no attribute 'control'

The error are jumping on this line:

Code:
controls = [elem.control for elem in self.program_buttons]

Do you know how I can find the button controls so I can use the setVisble method to hide for those controls?
Reply
#2
First, your code seems to make no sense at all, especially your list comprehension [elem.control for elem in self.program_buttons]. An elem object (ControlButton) indeed has no attribute 'control'. And applying .setVisible to a list returned by a list comprehension - what is this?

Second, ControlList is much better suited for displaying a set of items if arbitrary length.
Reply

Logout Mark Read Team Forum Stats Members Help
AttributeError: 'xbmcgui.ControlButton' object has no attribute 'control0