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

 

 

 

 

Drawing:

 

#Copyright (c) 2008 Pankaj Nathani

#Drawing on an image

#You can draw several shapes on images

import graphics, e32, appuifw
from math import pi


#Define the exit function
app_lock=e32.Ao_lock()
def quit():
    app_lock.signal()
appuifw.app.exit_key_handler=quit

canvas=appuifw.Canvas()
appuifw.app.body=canvas
appuifw.app.screen="full"

#Line
canvas.line((30,40,170,15), 0)
e32.ao_sleep(1)

#Rectangle
canvas.rectangle((30,45,110,100), fill=0xCC55EE) #Draws a purple rectangle
e32.ao_sleep(1)

#Dot
canvas.point((200,180), (253,46,103), width=4)
e32.ao_sleep(1)

#Ellipse
canvas.ellipse((22,260,58,280), fill=0x339900)
e32.ao_sleep(1)

app_lock.wait()

 

 

Opening:

 

#Copyright (c) 2008 Pankaj Nathani

#Opening an image or creating a blank one

import graphics, e32, appuifw


#Define the exit function
def quit():
    app_lock.signal()
appuifw.app.exit_key_handler=quit

canvas=appuifw.Canvas()
appuifw.app.body=canvas

#We open an existing picture
pic=graphics.Image.open("C:\\mypicture.jpg")
#And also make a blank one
img=graphics.Image.new((240,320)) #Remember to specify the appropriate size in pixels

canvas.blit(pic)
#Sets the background as the picture

#Wait 5 seconds
e32.ao_sleep(5)

canvas.blit(img)
#Sets the background to the blank image

app_lock=e32.Ao_lock()
app_lock.wait()

 

 

Editing an Image:

 

#Copyright (c) 2008 Pankaj Nathani

#Editing an image - resizing, transposing and saving

import graphics, e32, appuifw


#Define the exit function
def quit():
    app_lock.signal()
appuifw.app.exit_key_handler=quit

canvas=appuifw.Canvas()
appuifw.app.body=canvas

#We open the image we want to edit
img=graphics.Image.open("C:\\pic.jpg")

#We define the functions that do the editing and saving, for the menu
def resize():
    global img, canvas
    newx, newy=appuifw.multi_query([u"Enter width", u"Enter hight"]) #Asks for the new size
    img=img.resize((newx,newy))
    canvas.blit(img)

def transpose():
    global img, canvas
    img=img.transpose(ROTATE_90) #Rotates by 90 degrees
    canvas.blit(img)

def save():
    global img
    name=appuifw.query(u"Enter a name for the new image", "text")
    img.save("C:\\"+name+".jpg")

#Set the application's menu
appuifw.app.menu=[(u"Resize", resize), (u"Transpose", transpose), (u"Save", save), (u"Exit", quit)]

#Display the image
canvas.blit(img)

app_lock=e32.Ao_lock()
app_lock.wait()

 

 

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