Custom Search

Sunday, January 3, 2010

PyS60 Tutorial - Tab

PyS60 Tutorial - Tab

---------------------------------

Tab

To set tabs in the application to allow quick switching between views

/************ Complete Source Code Start *************/

import appuifw, e32

def quit():

app_lock.signal()

appuifw.app.exit_key_handler=quit

application1=appuifw.Text(u"This is application 1")

application2=appuifw.Text(u"This is application 2")

application3=appuifw.Text(u"This is application 3")

def tab_handler(index):

if(index==0):

appuifw.app.body=application1 # switch to application 1

if(index==1):

appuifw.app.body=application2 # switch to application 2

if(index==2):

appuifw.app.body=application3 # switch to application 3

appuifw.app.set_tabs([u"One", u"Two", u"Three"], tab_handler)

appuifw.app.body=application1

app_lock=e32.Ao_lock()

app_lock.wait()

/************ Complete Source Code End *************/

/*********** Description Start *************/

# Importing modules

import appuifw, e32

#Define the exit function 'quit'.

def quit():

app_lock.signal()

appuifw.app.exit_key_handler=quit

# Creating objects 'application1,application2 and application3' of Text Type.

# We define the applications for each tab:

application1=appuifw.Text(u"This is application 1")

application2=appuifw.Text(u"This is application 2")

application3=appuifw.Text(u"This is application 3")

# Create the function that switches between tabs

def tab_handler(index):

if(index==0):

# Setting body of the application as 'application1' that is tab-1.

appuifw.app.body=application1 # switch to application 1

if(index==1):

# Setting body of the application as 'application2' that is tab-2.

appuifw.app.body=application2 # switch to application 2

if(index==2):

# Setting body of the application as 'application3' that is tab-3.

appuifw.app.body=application3 # switch to application 3

# setting tabs in our application using method "set_tabs" of "Application" type object "app"

# Now we set the application's tabs.

# Here when we selecting a tab, the method 'set_tabs' call the callable object or function 'tab_handler' with

# the index of selected tab as an argument to it.

appuifw.app.set_tabs([u"One", u"Two", u"Three"], tab_handler)

# Setting default thing that appeared in the body of the application is 'application1'.

# Setting default body of the application as 'application1' that is tab-1.

# And we specify that the tab that is displayed first is tab -1

appuifw.app.body=application1

app_lock=e32.Ao_lock()

app_lock.wait()

/*********** Description End *************/

/************ Note Start *************/

# Text type is a text editor UI control.

# set_tabs(tab_texts [,callback=None])

set_tabs : is a method of "Application" Type object.

Sets tabs with given names on them in the navigation bar; tab_texts is a list of Unicode strings. When the users navigate

between tabs, callback(similar to function) gets called with the index of the active tab as an argument. Tabs can be disabled

by giving an empty or one-item tab_texts list. In List index start from 0.

# body

body : is an attribute of "Application" Type object.

The UI control that is visible in the application’s main window. Currently either Text, a Listbox object, Canvas, or None.

The thing that appeared in the body of the application.

/************ Note End *************/

No comments:

Post a Comment