2014-09-10, 16:02
Hi guys,
I have got a problem with my python code as it looks like it's the button issue. I'm adding the button controls in the tv guide skin to allow me to make the tv guide programs. Everything is working fine, but my only problem is the button controls. When I'm adding the button controls in the tv guide, most of the buttons will not make to get separate from the other button controls where you can see it.
Here is the screenshot:
Here is the code:
Here is the title log: http://xbmclogs.com/show.php?id=290053
Here is the program width log: http://xbmclogs.com/show.php?id=290056
Do you know how to make the button controls to make get seperate from the other button controls?
I have got a problem with my python code as it looks like it's the button issue. I'm adding the button controls in the tv guide skin to allow me to make the tv guide programs. Everything is working fine, but my only problem is the button controls. When I'm adding the button controls in the tv guide, most of the buttons will not make to get separate from the other button controls where you can see it.
Here is the screenshot:
Here is the code:
Code:
#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])
# find nearest half hour
viewStartDate = datetime.datetime.now()
viewStartDate -= datetime.timedelta(minutes = viewStartDate.minute % 30, seconds = viewStartDate.second)
try:
start_time = datetime.datetime.strptime(program_start_date, "%Y%m%d%H%M%S")
stop_time = datetime.datetime.strptime(program_end_date, "%Y%m%d%H%M%S")
except TypeError:
start_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(program_start_date, "%Y%m%d%H%M%S")))
stop_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(program_end_date, "%Y%m%d%H%M%S")))
#print start_time
startDelta = start_time - viewStartDate
stopDelta = stop_time - viewStartDate
program_start = self.secondsToXposition(startDelta.seconds)
#program_start is the size or after program
#print program_start
if startDelta.days < 0:
program_start = self.epgView.left
#print program_start
program_width_size = self.secondsToXposition(stopDelta.seconds) - program_start
if program_start + program_width_size > self.epgView.right:
program_width_size = self.epgView.right - program_start
idx = channel_index
program_notification = program
#workout the duration times to get the program time
program_duration = stop_time - start_time
#convert the datetime object between start_date and end_date
startDelta = start_time - viewStartDate
stopDelta = stop_time - viewStartDate
program_width = 0
if datetime.timedelta(minutes = 10) <= program_duration <= datetime.timedelta(minutes = 30):
program_width = 350
elif datetime.timedelta(hours = 1) <= program_duration <= datetime.timedelta(hours = 1.29):
program_width = 700
elif datetime.timedelta(hours = 1.30) <= program_duration <= datetime.timedelta(hours = 1.45):
program_width = 1050
elif datetime.timedelta(hours = 1.46) <= program_duration <= datetime.timedelta(hours = 2):
program_width = 1400
elif datetime.timedelta(hours = 2) <= program_duration <= datetime.timedelta(hours = 2.30):
program_width = 1750
elif datetime.timedelta(hours = 2.30) <= program_duration <= datetime.timedelta(hours = 3):
program_width = 2100
elif datetime.timedelta(hours = 3) <= program_duration <= datetime.timedelta(hours = 3.30):
program_width = 2450
elif datetime.timedelta(hours = 3.30) <= program_duration <= datetime.timedelta(hours = 4):
program_width = 2800
elif datetime.timedelta(hours = 4) <= program_duration <= datetime.timedelta(hours = 4.30):
program_width = 3150
elif datetime.timedelta(hours = 4.30) <= program_duration <= datetime.timedelta(hours = 5):
program_width = 3500
elif datetime.timedelta(hours = 5) <= program_duration <= datetime.timedelta(hours = 5.30):
program_width = 3850
elif datetime.timedelta(hours = 5.30) <= program_duration <= datetime.timedelta(hours = 6):
program_width = 4200
elif datetime.timedelta(hours = 6) <= program_duration <= datetime.timedelta(hours = 6.30):
program_width = 3250
elif datetime.timedelta(hours = 6.30) <= program_duration <= datetime.timedelta(hours = 7):
program_width = 4550
elif datetime.timedelta(hours = 7) <= program_duration <= datetime.timedelta(hours = 7.30):
program_width = 4900
elif datetime.timedelta(hours = 7.30) <= program_duration <= datetime.timedelta(hours = 8):
program_width = 5250
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 < 65:
program_title = ''
else:
program_title = title
program_start = int(program_width) + 40
program_height = 35
program_top = 315 + 37.5 * idx
if not program_top % 1.0:
program_top = int(program_top)
print program_title
program_controls = xbmcgui.ControlButton(
program_start,
program_top,
program_width,
program_height,
program_title,
focusTexture = button_focus,
noFocusTexture = button_nofocus
)
focusFunction = None
# add program controls
if focusFunction is None:
focusFunction = self.findControlAt
focusControl = focusFunction(self.focusPoint)
self.addControl(program_controls)
cur.close()
Here is the title log: http://xbmclogs.com/show.php?id=290053
Here is the program width log: http://xbmclogs.com/show.php?id=290056
Do you know how to make the button controls to make get seperate from the other button controls?