How to navigate the timeline buttons?
#1
Hi guys,

I need your help, I've modified the tv guide addon (http://wiki.xbmc.org/index.php?title=Add-on:TV_Guide)

I have added the list of buttons for the channels and programs in the tv guide. I have one yellow image in the channel button and one yellow image in the program button. I want to know how I can navigate the timeline with up/down/left/right buttons in the tv guide??

Here is the screenshot:

Image



Here is the code:

Code:
#get actioncodes from keyboard.xml
ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4

def Channels(self):
    for row in programs:
        program = row[1].encode('ascii'), str(row[2]), str(row[3])
        title = row[1].encode('ascii')
        program_start_date = str(row[2])
        program_end_date = str(row[3])                      

        #convert the date formats into minutes
        minutes_start = self.parseDateTimeToMinutesSinceEpoch(program_start_date)
        minutes_end = self.parseDateTimeToMinutesSinceEpoch(program_end_date)
        minutes_length = minutes_end - minutes_start

        program_length = minutes_length
        program_notification = program
        programs_top = 315
        program_height = 34.5
        program_gap = 2.5
        position_start = start_pos
        position_top = programs_top + channel_index * (program_height + program_gap)


        if 10 <= program_length < 60:
            program_width = 342.5
        elif 60 <= program_length < 90:
            program_width = 690
        elif 90 <= program_length < 105:
            program_width = 1050
        elif 105 <= program_length < 120:
            program_width = 1400
        elif 120 <= program_length < 150:
            program_width = 1750
        elif 150 <= program_length < 180:
            program_width = 2100
        elif 180 <= program_length < 210:
            program_width = 2450
        elif 210 <= program_length < 240:
            program_width = 2800
        elif 240 <= program_length < 270:
            program_width = 3150
        elif 270 <= program_length < 300:
            program_width = 3500
        elif 300 <= program_length < 330:
            program_width = 3850
        elif 330 <= program_length < 360:
            program_width = 4200
        elif 360 <= program_length < 390:
            program_width = 3250
        elif 390 <= program_length < 420:
            program_width = 4550
        elif 420 <= program_length < 450:
            program_width = 4900
        elif 450 <= program_length < 480:
            program_width = 5250

        start_pos += program_width + 2 * program_gap

        if program_width > 1:
            if yellow_flag:
                if program_notification:
                    button_nofocus = 'changelang_yellow.png'
                    button_focus = 'channels_bar1.png'
                else:
                    button_nofocus = 'changelang_yellow.png'
                    button_focus = 'channels_bar1.png'
                    yellow_flag = False
                    text_color = '0xFF000000'

            else:
                if program_notification:
                    button_nofocus = 'channels_bar1.png'
                    button_focus = 'channels_yellow.png'
                else:
                    button_nofocus = 'channels_bar1.png'
                    button_focus = 'channels_yellow.png'
                text_color = '0xFFFFFFFF'

                if program_width < 1:
                    program_title = ''
                else:
                    program_title = '[B]' + title + '[/B]'


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


def onAction(self, action):
    if action == ACTION_MOVE_LEFT:



    if action == ACTION_MOVE_RIGHT:



    if action == ACTION_MOVE_UP:



    if action == ACTION_MOVE_DOWN:


Do you know how??

If you need to take a look on my full code, here it is: https://github.com/Pr0ph3cyTiger/script.tvguide/
Reply
#2
does anyone know how I can navigate the timeline with up/down/left/right buttons in the tv guide?
Reply
#3
I'm can't think of a good way to do this. (Which isn't to say others can't - just that any way to do it well is beyond my knowledge).

From what I can see from the Python docs, there's no way to set the ID of controls you add. If there was, then you'd give each control an ID, then set the buttons controlLeft, controlRight, controlUp and controlDown properties to move between the buttons - so you'd give the first button an id of 1000, controlRight would be 1001, controlDown 2001 and so on (though even if this were possible, it'd take some great Python skills with different button widths to work out which buttons were above and below each button, so the navigation moved to the correct button when going up and down.)

Assuming there isn't a hidden setID method, you could possibly do this by providing a skin .xml file with a number of grouplist controls, with their up and down set to move between each other. By adding buttons to them, they would then take care of moving left and right between buttons in a single row. But that's not something I've ever tried, so may not be possible itself. Undecided
Reply
#4
Thank you for your advice, I'm going to use the grouplist controls. Do you know how easy to code the grouplist controls to allow me to take the control of channels and programs?

Do I need to remove the button code (that allow me to add the list of programs) to replace with the grouplist control?
Reply
#5
Can't advise you any further (and I wouldn't even call it advice because, as I said, it's not something I've ever tried - it's just a suggestion Smile)
Reply

Logout Mark Read Team Forum Stats Members Help
How to navigate the timeline buttons?0