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.
This code doesn't work because pixel(0,0) is the wrong pixel !
You must take the pixel of the frame ie where you begin to draw fg !
I also remarked that bar init with white color (0xFFFFFF) ! If you begin with status_on()
init bar with bgcolor first.
Thus bgcolor is white and you draw text in white also ! You display anything !
Here's new version with complete example:
keep on the good work !