Start PyS60 Tutorials PyS60 Talks Applications Buzz Us Blog

 

Notification, Menus and Forms. Canvas, Content Handler and Queries. Set application title, tabs and set application body. Application screen size and Application Orientation. Text to speech, Playing and Recording sounds and setting volume. Taking a Photo, Recording Video and Using Viewfinder. Accessing Contacts and Adding - Deleting Contact entries. Using the e32 Module. Drawing, Opening and Editing an Image. Checking the Inbox, Reading SMS, Deleting SMS and Waiting for a SMS. Setting Logs, Retrieving Last missed calls, Retrieving Last SMS. Sending SMS, MMS, Email. Battery and Signal, Free Ram and Free Space, IMEI and firmware, phones, display, etc. Making a call, Hanging up calls, Waiting for a call. Displaying Text and showing an Image on a Window. Avoiding Python to be terminated by Red Key and Hiding the shell. Global Notifications and Queries.

 

 

      ADVERTISEMENT

 

 

 

 

Canvas:

 

 

#Copyright (c) 2008 Pankaj Nathani

 

#Canvas

 

#The application's body can be set to Canvas, which is used mainly for displaying images

 

import appuifw, graphics, e32

 

 

#Define the exit function

def quit():

app_lock.signal()

appuifw.app.exit_key_handler=quit

 

#We define a method that will place the image myimage on the canvas:

def handle_redraw(rect):

c.blit(myimage)

 

#We open myimage

myimage=graphics.Image.open("C:\\myimage.jpg")

#or we make a blank one, specifying its size in pixels

myimage=graphics.Image.new((240,320))

 

c=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)

#This sets c as a canvas which can be redrawn and can be modified if certain events (in this case key presses) occur if you make a method for that

 

appuifw.app.body=c

 

c.text((20,30), u"something", font="title")

#Here the text is displayed at the specified coordinates on the canvas, with the title font, if the 1 button is pressed

#Other font types are normal, default, dense, symbol, annotation, and legend. You can also use other formats, as is explained below

 

#As you've seen above, you can write text on a canvas.

#An additional way of specifying the parameters is:

c.text((2,24), u'Hello', 0x008000, font=(u'Nokia Hindi S60',48,appuifw.STYLE_BOLD))

#Here 0x008000 is the color of the text, 48 is its size and appuifw.STYLE_BOLD is its style

 

#The canvas can also be cleared (and optionally filled with a color)

c.clear()

#c.clear(0x008000) fills it with green

 

app_lock=e32.Ao_lock()

app_lock.wait()

 

 

Content Handler:

 

#Copyright (c) 2008 Pankaj Nathani #Content handler

#Open any supported file type with its designated application

import appuifw

a=appuifw.Content_handler()
a.open("C:\\movie.mpg")
#This opens the video file with RealPlayer, or whatever the default player is.

 

 

Queries:

 

    

 

    

 

  

 

#Copyright (c) 2008 Pankaj Nathani

 

#Queries

 

#General form: query(label, type[, initial_value ])

 

import appuifw

 

#You can store the information entered by the user in a variable

 

inf=appuifw.query(u"Enter a number", "number")

#asks for a number, in this case integer; for a fractional number use "float"

 

inf=appuifw.query(u"Enter a word", "text")

#asks for a text

 

inf=appuifw.query(u"Enter a password", "code")

#asks for a password, and shows the characters as "*" for protection

 

inf=appuifw.query(u"Enter a time", "time")

#asks for a time in hh:mm format

 

inf=appuifw.query(u"Would you like to play again?", "query")

#displays a question, the returned values being 1 if the user has selected "Yes" and 0 if the user has selected "No"

 

inf=appuifw.multi_query(u"Part1", u"Part2")

#asks for two fields of information

 

 

       Copyright © Croozeus.com All rights reserved.                                                                                                                        Webdesign: Jackson Productions