×
Namespaces

Variants
Actions
Revision as of 11:45, 2 January 2009 by bogdan.galiceanu (Talk | contribs)

Archived:How to use tabs in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
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: (18 Jul 2007)
Last edited: bogdan.galiceanu (02 Jan 2009)

Contents

Overview

This snippet shows how to use tabs in Python.

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)
66 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×