Skip to content

Commit 47e7750

Browse files
author
Kai Aras
committed
implemented writeText method
1 parent 674522a commit 47e7750

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

pymw.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ def writeimage(self,mode=0,image="template.bmp", live=False):
139139
self.updatedisplay(mode=mode);
140140
time.sleep(0.1);
141141
self.updatedisplay(mode=mode);
142+
143+
144+
def writeText(self,mode=0,text=''):
145+
import Image,ImageDraw
146+
image = Image.new("1",(96,96))
147+
draw = ImageDraw.Draw(image)
148+
draw.text((1,1),text,fill='white')
149+
image.save('tmp.bmp','BMP')
150+
self.writeimage(mode,"tmp.bmp",live=True)
151+
142152
def updatedisplay(self,mode=0,activate=1):
143153
"""Update the display to a particular mode."""
144154
if activate: mode=mode|0x10;
@@ -347,14 +357,15 @@ def main():
347357
if len(sys.argv)>2:
348358
imgfile=sys.argv[2];
349359

350-
351-
#Push a bird into the buffer.
352-
try:
353-
mw.writeimage(mode=mode,image=imgfile,live=True);
354-
except ImportError:
355-
print "Error, Python Imaging Library (PIL) needs to be installed"
356-
except:
357-
print "Error loading image. Probably not in the working directory.";
360+
361+
mw.writeText(mode,"Hello World")
362+
# #Push a bird into the buffer.
363+
# try:
364+
# mw.writeimage(mode=mode,image=imgfile,live=True);
365+
# except ImportError:
366+
# print "Error, Python Imaging Library (PIL) needs to be installed"
367+
# except:
368+
# print "Error loading image. Probably not in the working directory.";
358369

359370
#Test the writing function by writing a checker pattern.
360371
#mw.testwritebuffer(mode=mode);

0 commit comments

Comments
 (0)