Namespaces
Variants
Actions

Archived:How to draw directly to the phone screen using PySymbian

Jump to: navigation, search
Archived.png
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.
Article Metadata

Tested with
Devices(s): S60 3rd Edition FP1 SDK

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

Article
Keywords: fgimage
Created: cyke64 (19 Mar 2007)
Last edited: hamishwillee (08 May 2013)

Introduction

You can draw directly to the phone screen. It is useful for a notification from a background program. You need to install fgimage module :

Code Snippets

The following code snippet draws hello world and clears it after 1 second.

import fgimage, e32
from graphics import Image
 
img = Image.new((100, 16)) # create a notification text
img.text((0, 14), u'Hello world', 0)
 
fg = fgimage.FGImage()
x, y = 0, 40 # position to draw
fg.set(x, y, img._bitmapapi()) # send it
 
e32.ao_sleep(1)
fg.unset() # then clear it
import e32
from graphics import *
import fgimage
 
img = Image.new((100, 16))
fg = fgimage.FGImage()
text = u"This is where the text goes"
 
# Does simple scrolling
i = 0
while i < len(text):
 
img.clear((0, 255, 255))
img.text((0, 14), text[i:], 0)
fg.set(0, 40, img._bitmapapi())
e32.ao_sleep(0.2) # 200 ms sleep
i += 1
 
fg.unset()

The following code snippet draws on the phone screen, fetches the pixel value and draws the same pixel somewhere else.

import e32
from graphics import *
import fgimage
 
 
image = Image.new((176, 208))
image.point((10,10), 0x00ff00, width=10) # green
value = fgimage.getpixel(10, 10, img._bitmapapi())
img.point((20,20), value, width=1)
print hex(value)
 
def drawit():
canvas.blit(image)
 
appuifw.app.body = canvas = appuifw.Canvas()
drawit()
e32.ao_sleep(5)

See Also

This page was last modified on 8 May 2013, at 09:10.
131 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved