You Are Here:

Community: Developer Discussion Boards

#1 Old appuifw font menu display - 2006-11-14, 19:30

Join Date: Apr 2003
Posts: 6
dmac2003
Offline
Registered User
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...
I'd would like this text above to be displayed like the popup screen and font in this screen shot:
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
newbi question: building apps with rss files mrabie Symbian Tools & SDKs 1 2002-10-14 11:46

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia