[Tutor] banners
Juhász János
juhasz.jani at freemail.hu
Sat Aug 26 22:04:47 CEST 2006
I have continued to work on making banners:)
Here is a solution with PIL
(http://www.pythonware.com/products/pil/index.htm):
import Image, ImageFont, ImageDraw
ShowText = 'Hi all'
font = ImageFont.load(r'c:\Python24\Lib\site-
packages\enthought\kiva\pil_fonts\courier-bold-10.pil')
size = font.getsize(ShowText)
image = Image.new('1', size, 1)
draw = ImageDraw.Draw(image)
draw.text((0, 0), ShowText, font=font)
for rownum in range(size[1]):
for colnum in range(size[0]):
if image.getpixel((colnum, rownum)): print " ",
else: print "#",
print ''
If your pil font file is in a different directory, you have to change it.
It produces the next output for me anyway:
# # # # # # # #
# # # # # # # #
# # # # # # # # # # # # # #
# # # # # # # # # # # # # # #
# # # # # # # # # # # # # #
# # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
Janos Juhasz
______________________________________________________________________
Adómegtakarítás augusztusban? Ne dobja ki pénzét feleslegesen!
http://www.klikkbank.hu/befektetes/index.html
More information about the Tutor
mailing list