# Archived:How to make Random Rectangle in PySymbian- Part 1

Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

This PySymbian code snippet shows how to use the graphics moduleto draw a random number of randomly coloured rectangles.

Tested with
Devices(s): N70, N96

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

Platform Security
Signing Required: Self-Signed
Capabilities: None

Article
Keywords: appuifw, time, math, graphics
Created: james1980 (31 Dec 2008)
Last edited: hamishwillee (08 May 2013)

## Code Snippet

`import e32,randomimport timeimport appuifwimport graphicsimport math appuifw.app.title = u"Random Rectangles" #set the application titlecan=appuifw.Canvas()  #create a canvas classappuifw.app.body=can  # assign canvas to the application bodyimg=graphics.Image.new(can.size) #created a new imageimg.clear(0xffffff)  # cleared the image running=1def quit():    global running    running=0appuifw.app.exit_key_handler=quit while running:   # below script draws random rectangles     a=random.randrange(255)  #defining the colours of rectangles    b=random.randrange(255)    c=random.randrange(255)    j=can.size[0]    k=can.size[1]     x1=(random.randrange(j-10))  #defining the position of the rectangles    y1=(random.randrange(j-10))    x2=x1+10    y2=y1+10    img.rectangle((x1,y1,x2,y2),outline=None,fill=(a,b,c)) #drawing rectangles    img.rectangle((x1+10,y1+10,x2-10,y2-10),outline=None,fill=0xffffff)    can.blit(img)  #blitting the rectangles on the image    e32.ao_sleep(.1)        e32.ao_yield()`

## Screenshots

The screenshots below clearly explains the functionality of above code snippet.