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

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« 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)
   1  
   2  # status.py
   3  from graphics import *
   4  import fgimage
   5  __all__ = ["status_on", "status_off"]
   6  
   7  bar = Image.new((119,13))
   8  bgcolor = screenshot().getpixel((0,0))[0]
   9  fg = fgimage.FGImage()
  10  
  11  def status_on(message=None):
  12      if message is not None:
  13          bar.clear(bgcolor)
  14          bar.text((0,11), unicode(message), 0xffffff)
  15      fg.set(57,30, bar._bitmapapi())
  16  
  17  def status_off():
  18      fg.unset()

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

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.
   1  
   2  import fgimage, e32
   3  
   4  img = Image.new((100, 16))  # create a notification text
   5  img.text((0, 14), u'Hello world', 0)
   6  
   7  fg = fgimage.FGImage()
   8  x, y = 0, 40           # position to draw
   9  fg.set(x, y, img._bitmapapi())  # send it
  10  
  11  e32.ao_sleep(1)
  12  fg.unset()                # then clear it


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