JJD
JJD

Reputation: 412

Python PIL with variable

I have very little python experience but currently playing with PIL (Python Image Library) I am trying to get a variable printed to a screen but cant seem to get it to work. I have tried several things but nothing has worked yet, this is just test code but I'm trying to get it to display the count.

x=0
while x < 100:
    noki.cls
    time.sleep(1)
    im = Image.new('1', (84,48))
    draw = ImageDraw.Draw(im)
    draw.line((0,10, 84,10), fill=1)
    draw.text((30,0), "JEFF", fill=1)
    draw.text((20,10), "count: %x", fill=1)
    x = x + 1
    noki.show_image(im)
    del draw
    del im

Thanks for the help!

Upvotes: 0

Views: 281

Answers (1)

John1024
John1024

Reputation: 113994

draw.text((20,10), "count: %s" % x, fill=1)

For more information, read about python's string interpolation.

Upvotes: 2

Related Questions