Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Showing message on status bar

There's an empty space below app.title that we can
use as a status bar. So, I modify this recipe and
make it into a module. (need fgimage.pyd from here)
# status.py
from graphics import *
import fgimage
__all__ = ["status_on", "status_off"]

bar = Image.new((119,13))
bgcolor = screenshot().getpixel((0,0))[0]
fg = fgimage.FGImage()

def status_on(message=None):
    if message is not None:
        bar.clear(bgcolor)
        bar.text((0,11), unicode(message), 0xffffff)
    fg.set(57,30, bar._bitmapapi())

def status_off():
    fg.unset()

You can use it easily this way
>>> from status import *
>>> status_on('Hello world')  # show it
>>> status_off()              # hide it
>>>

See a screenshot.

Using foreground image

You can draw directly to the phone screen.
It is useful for a notification from a background program.
You need to install fgimage.pyd from here.
import fgimage, e32

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


See (a bit) more discussion here.
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS