| Reply | « Previous Thread | Next Thread » |
|
hi guys im new and exploring PyS60...
im trying out some code, and have coded an app that retreives an .xml file from a web url. This is then passed to internal memory on the phone, and i then pick out various xml attributes and their properties, so i can display them to the user... (It scans various tags within the xml file.) what i need to know is what is the best way to display text which will be in the following format on the screen: Code:
Home team: xyz Away team: xyz Status: : xyz HalfTimeScore: xx FullTimeScore: xx GameNumber: xxxx PubDate: xxxxx Country: xxxxx etc... http://www.traxmusic.org/temp/Screenshot0002.jpg a popup menu, with small enough text. is it possible to change the font size in: appuifw.popup_menu any thoughts appreciated. thank you. Darren. see code below: Code:
# - Darren McEntee, 14/11/2006
# - Python application to get latest scores from
# Exactscores.com - SoccerLivescoreXml.xml
# - Parses the xml data, hunts down specific values and displays the correct data.
# imports
import socket
import urllib
import e32
import appuifw
# menu choice
choices =[(u"LiveResults(1)", "Football Livescore(1)"),
(u"---", "---"),
(u"---", "---")]
choices_labels = [x[0] for x in choices]
exactscores_url_base = "http://www.exactscores.com/SoccerLivescoreXml.xml" # live score url to xml data
tempfile = "c:\\SoccerLivescoreXml.xml" # store the xml data locally
# function to find the <start> and </end> tag in question
def find_value(text, tag):
"Find the value between <tag> and </tag> in text. Always returns a string"
begin_tag = "<" + tag + ">"
begin = text.find(begin_tag)
end = text.find("</" + tag + ">")
if begin == -1 or end == -1:
return ""
begin += len(begin_tag)
return text[begin:end]
def handle_selection():
index = lb.current()
code = choices[index][1]
scores_url = exactscores_url_base # + code + ".xml"
lb.set_list([u"Please wait..."]) # notify user that its 'doing work'
appuifw.note(u"Fetching "+ scores_url, 'info')
try:
urllib.urlretrieve(scores_url, tempfile) # fetches the SoccerLivescoreXml.xml and passes it to 'tempfile' that wil be stored locally.
f = open(tempfile, 'r') # open's the file (readonly), passes to variable 'f'
SoccerLivescoreInfo = f.read() # passes to internal variable
f.close() # closes the file
# get our specific elements from the xml file: SoccerLivescoreRss.xml
GameNumber = find_value(SoccerLivescoreInfo, "Number")
print "GameNumber is: " +GameNumber
HomeTeam = find_value(SoccerLivescoreInfo, "HomeTeam")
print "HomeTeam is: " +HomeTeam
AwayTeam = find_value(SoccerLivescoreInfo, "AwayTeam")
print "AwayTeam is: " +AwayTeam
Status = find_value(SoccerLivescoreInfo, "Status")
print "Status is: " +Status
HalfTimeScore = find_value(SoccerLivescoreInfo, "HalfTime")
print "HalfTime is: " +HalfTimeScore
FullTimeScore = find_value(SoccerLivescoreInfo, "FullTime")
print "FullTime is: " +FullTimeScore
PubDate = find_value(SoccerLivescoreInfo, "PubDate")
print "PubDate is: " +PubDate
Country = find_value(SoccerLivescoreInfo, "Country")
print "Country is: " +Country
# popupMenu
appuifw.app.body = None
#listing1 = [u"Game: " +GameNumber, u"Home: " +HomeTeam, u"Away: " +AwayTeam, u"Status: " +Status, u"HT: " +HalfTimeScore, u"FT: " +FullTimeScore, u"Date: " +PubDate, u"Country: " +Country]
listing1 = [u"Teams: " +HomeTeam, u" Vs " +AwayTeam, u"Status: " +Status, u"HT: " +HalfTimeScore, u"FT: " +FullTimeScore, u"Date: " +PubDate, u"Country: " +Country]
appuifw.popup_menu( listing1, u'My List' )
except IOError:
appuifw.note(u"Connection error to server", 'error')
except:
appuifw.note(u"Could not fetch information", 'error')
lb.set_list(choices_labels)
def handle_add():
pass
def handle_delete():
pass
def exit_key_handler():
app_lock.signal()
lb = appuifw.Listbox(choices_labels, handle_selection)
old_title = appuifw.app.title
appuifw.app.title = u"Football Livescore(00)"
appuifw.app.body = lb
appuifw.app.menu = [(u"Add new item", handle_add),
(u"Delete item", handle_delete)]
appuifw.app.exit_key_handler = exit_key_handler
app_lock = e32.Ao_lock()
app_lock.wait()
appuifw.app.title = old_title
Last edited by dmac2003 : 2006-11-14 at 23:07.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| newbi question: building apps with rss files | mrabie | Symbian Tools & SDKs | 1 | 2002-10-14 11:46 |