Hi guys
I have added the list of buttons for the channels and programs in the tv xbmc guide. I have one yellow image in the channel button and I have one yellow image in the program button. I want to know how I can navigate the timeline with up, down, left and right buttons when I press on the arrow buttons of the keyboard?
Here is the screenshot:
Here is the code:
#get actioncodes from keyboard.xml
ACTION_MOVE_LEFT = 1
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_UP = 3
ACTION_MOVE_DOWN = 4
def cSetVisible(WiNdOw,iD,V=True): WiNdOw.getControl(iD).setVisible(V)
ADDON = xbmcaddon.Addon(id = 'script.tvguide')
class MyClass(xbmcgui.WindowXML):
def All_Channels(self):
#Pull the data from the database
channelList = list()
database_path = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', 'source.db'))
if os.path.exists(database_path):
#get the channels list
cur.execute('SELECT channel FROM programs WHERE channel GROUP BY channel')
for row in cur:
channels = row[0].encode('ascii')
channelList.append(channels)
# set the channels text
for index in range(0, CHANNELS_PER_PAGE):
channel = channelList[index]
channel_index = index
if channel is not None:
self.getControl(4110 + index).setLabel(channel)
#get the programs list
cur.execute('SELECT channel, title, start_date, stop_date FROM programs WHERE channel=?', [channel])
programList = list()
programs = cur.fetchall()
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_index = channel_index
program_start = channel_index * 60
program_length = minutes_length
program_notification = program
program_minutes = minutes_length
program_start_to_end = 100
programs_top = 325
program_height = 34.5
pixels_per_minute = 1080 / minutes_length
program_gap = 10
position_start = program_start_to_end + (program_start * pixels_per_minute) + ((program_index - 1) * program_gap)
position_top = programs_top + (channel_index * program_height) + ((channel_index - 1) * program_gap)
program_width = program_length * pixels_per_minute
if program_width > 1:
if program_notification:
button_nofocus = 'channels_bar1.png'
button_focus = 'channels_yellow.png'
else:
button_nofocus = 'channels_bar1.png'
button_focus = 'channels_yellow.png'
if program_width < 1:
program_title = ''
else:
program_title = title
program_controls = xbmcgui.ControlButton(
position_start,
position_top,
program_width,
program_height,
program_title,
focusTexture = button_focus,
noFocusTexture = button_nofocus
)
self.addControl(program_controls)
cur.close()
def onAction(self, action):
if action == ACTION_MOVE_RIGHT:
if allchannels_enabled:
#move the yellow image to the next button
pass
if action == ACTION_MOVE_LEFT:
if allchannels_enabled:
#move the yellow image to the next button
pass
if action == ACTION_MOVE_UP:
if allchannels_enabled:
#move the yellow image to the next button
pass
if action == ACTION_MOVE_DOWN:
if allchannels_enabled:
#move the yellow image to the next button
pass
Do you know how I can navigate the timeline with up, down, left and right buttons when i press on the arrow buttons of the keyboard so i can then change the images on each button?