2014-03-05, 01:22
Hi,
Im very noob in programming for xbmc, im trying to display time clock in xbmc but the time dont update ever second its get stoped.
Please give me a hand help on this.
Thank you all
Im very noob in programming for xbmc, im trying to display time clock in xbmc but the time dont update ever second its get stoped.
Code:
import calendar
import datetime
import sys
import os
import xbmc
import xbmcgui
import xbmcaddon
import socket
import serial
import time
import Tkinter as tk
from Tkinter import *
import string
#os.system("sudo shutdown -h now")
ACTION_PREVIOUS_MENU = 10
ACTION_SELECT_ITEM = 7
TEXT_ALIGN_LEFT = 0
TEXT_ALIGN_RIGHT = 1
TEXT_ALIGN_CENTER_X = 2
TEXT_ALIGN_CENTER_Y = 4
TEXT_ALIGN_RIGHT_CENTER_Y = 5
TEXT_ALIGN_LEFT_CENTER_X_CENTER_Y = 6
class RadioFM(xbmcgui.WindowDialog):
def __init__(self):
#xbmc.executebuiltin("XBMC.ActivateWindow(Programs)")
self.retval=0
self.clientScript=os.path.join(addon.getAddonInfo('path'),'resources','radio_client.py')
self.stations=os.path.join(addon.getAddonInfo('path'),'resources','stations')
self.mediaPath=os.path.join(addon.getAddonInfo('path'),'resources','media') + '/'
# Open socket for communication with the radio_server.py
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
# Background
self.w=1280
self.h=720
self.background=xbmcgui.ControlImage(0,0,self.w,self.h,self.mediaPath + 'background.jpg',
colorDiffuse='0xff777777')
self.addControl(self.background)
# Current Frequency label
self.current_freq=xbmcgui.ControlLabel(
self.w/3 - 400, 0,
800, 100,
addon.getLocalizedString(id=30000),
textColor='0xffffffff',
font='DejaVuSansB160',
alignment=TEXT_ALIGN_LEFT)
self.addControl(self.current_freq)
# Presets Configuration
self.presets_start_x = 100
self.presets_start_y = 570
self.presets_offset_x = 220
self.presets_width = 200
self.presets_height = 100
self.presets_font = 'WeatherTemp'
self.presets_color = '0xFFFFFFFF'
self.presets_img = self.mediaPath + 'textures/floor_buttonfo.png'
self.presets_img_focus = self.mediaPath + 'textures/floor_button.png'
# Menu button
self.home_button=xbmcgui.ControlImage(0,0,70,70,
self.mediaPath + 'textures/icon_home.png',
colorDiffuse='0xffffffff')
self.button_menu=xbmcgui.ControlButton(0,0,70,70,
"",
self.mediaPath + 'textures/floor_buttonfo.png',
self.mediaPath + 'textures/floor_button.png',
0,
0)
self.addControl(self.button_menu)
self.setFocus(self.button_menu)
self.addControl(self.home_button)
self.strAction2 = xbmcgui.ControlLabel(300 + self.presets_offset_x * 1,-1,800,self.presets_height, '','WeatherTemp70', self.presets_color,alignment=TEXT_ALIGN_CENTER_X)
self.addControl(self.strAction2)
self.date = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H-%M-%S")
self.strAction2.setLabel(self.date)
def onControl(self, controlID):
if controlID == self.button_menu:
# Go to Home Window
xbmc.executebuiltin("XBMC.ActivateWindow(Home)")
self.retval=0
self.sock.close()
self.close()
addon = xbmcaddon.Addon(id='plugin.program.radioFM')
finished=0
today = datetime.datetime.today()
currentday=int(today.strftime('%d'))
currentmonth=int(today.strftime('%m'))
month=currentmonth
currentyear=int(today.strftime('%Y'))
while finished == 0:
dialog=RadioFM()
dialog.doModal()
if dialog.retval == 0:
finished = 1
del dialog
del addon
Please give me a hand help on this.
Thank you all