Community: Blogs

你在这里: You Are Here: Olet tässä: Vous êtes ici: Sie befinden sich hier: Tu sei qui: 現在のページ: Você está aqui: Вы здесь: Usted está aquí:

Tasty Multimedia Journal's Forum Nokia Blog

Multi-view UI Design in Python for S60 -- this works

kevin_s2f | 13 July, 2007 02:26

Thanks to Lfd over in the PyS60 Forum here, I now have a better handle on view switching in Python. Now, when I execute a call-back function that needs to change attributes of the UI (from a listbox to canvas, for example) it's a simple task of wrapping the function with some state preservation and restoration code. 

What you see here is simple assignments, but exanding on Lfd's suggestion one could easily package all the attributes into a state tuple, push the tuple on a view stack, and pop views off the stack as needed.

Here is the simple case:

def takepic(filename):
    import camera
    # save UI elements
    oldBody = appuifw.app.body
    oldExit = appuifw.app.exit_key_handler
    oldFocus = appuifw.app.focus
    oldMenu = appuifw.app.menu
    oldScreen = appuifw.app.screen
    oldTitle = appuifw.app.title
    appuifw.app.title = u"Let us take a picture here."
    im = camera.take_photo()  # use all default values -- eventually this fn will change *.body into canvas control for viewfinder
    im.save(u'e:test.jpg')
    #restore UI elements
    appuifw.app.body = oldBody
    appuifw.app.exit_key_handler = oldExit
    appuifw.app.focus = oldFocus
    appuifw.app.menu = oldMenu
    appuifw.app.screen = oldScreen
    appuifw.app.title = oldTitle
 
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Invite a friend Invite a friend
E-mail Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us Regional websites: Chinese Japanese © 2008 Nokia 
RDF Facets: qfnZtypeQUqfnTypeZBlogContentQ qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX