【发布时间】:2014-06-17 19:08:20
【问题描述】:
我正在为 xbmc 媒体应用程序编写我的 python 脚本,以将请求发送到 url 以获取响应,以便我可以将数据存储在 sqlite3 数据库中。
我想为标签控件设置从 0% 到 100% 的计算进度,以查看当我将请求发送到 url 以获取响应然后将数据存储在数据库中时我走了多远.
这是我要使用的控件 ID:
main_loading_time_left = 4202
代码如下:
#DOWNLOAD THE XML SOURCE HERE
url = ADDON.getSetting('url')
req = urllib2.Request(url)
response = urllib2.urlopen(req)
data = response.read()
response.close()
profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', ''))
if os.path.exists(profilePath):
profilePath = profilePath + 'source.db'
con = database.connect(profilePath)
cur = con.cursor()
cur.execute('CREATE TABLE programs(channel TEXT, title TEXT, start_date TIMESTAMP, stop_date TIMESTAMP, description TEXT)')
con.commit()
con.close
tv_elem = ElementTree.parse(StringIO.StringIO(data)).getroot()
profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', ''))
profilePath = profilePath + 'source.db'
con = sqlite3.connect(profilePath)
cur = con.cursor()
channels = OrderedDict()
# Get the loaded data
for channel in tv_elem.findall('channel'):
channel_name = channel.find('display-name').text
for program in channel.findall('programme'):
title = program.find('title').text
start_time = program.get("start")
stop_time = program.get("stop")
cur.execute("INSERT INTO programs(channel, title, start_date, stop_date)" + " VALUES(?, ?, ?, ?)", [channel_name, title, start_time, stop_time])
con.commit()
有谁知道我如何使用控件 ID main_loading_time_left 来设置从 0% 到 100% 的计算进度,当我将请求发送到 url 以获取响应然后将数据存储到数据库中时.有人知道怎么做吗?
【问题讨论】: