Namespaces
Variants
Actions
(Redirected from How to use tabs)

Archived:How to use tabs in PySymbian

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata

Tested with
Devices(s): Nokia N95, Nokia E90

Compatibility
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition

Article
Keywords: appuifw
Created: lfd (18 Jul 2007)
Last edited: hamishwillee (08 May 2013)

This snippet shows how to use tabs in Python.

Contents

Source code

import appuifw, e32
 
 
#Create an active object
app_lock = e32.Ao_lock()
#Define the exit function
def quit():
app_lock.signal()
appuifw.app.exit_key_handler = quit
 
#Define the tabs
tab1 = appuifw.Text(u"This is tab #1")
tab2 = appuifw.Text(u"This is tab #2")
tab3 = appuifw.Text(u"This is tab #3")
 
#Create a tab handler that switches between tabs
def handle_tab(index):
#Switch to the tab according to index
if(index==0):
appuifw.app.body = tab1
if(index==1):
appuifw.app.body = tab2
if(index==2):
appuifw.app.body = tab3
 
##Set the tabs
appuifw.app.set_tabs([u"One", u"Two", u"Three"], handle_tab)
 
#Set the default tab to the first tab, for example
appuifw.app.body = tab1
 
#Wait for the user to request the exit
app_lock.wait()

Postconditions

Tabs are displayed as appuifw.Text() objects and the user can switch between them by using the left and right navigation keys.

Tabs.jpg

Observations

When running a script that implements tabs in the Script Shell, after the script execution returns the tabs are still visible. To avoid this, add this in the exit function, above the line that signals the active object:

#Remove tabs and their handler function
appuifw.app.set_tabs([], None)
This page was last modified on 8 May 2013, at 08:15.
201 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved