Is it possible to use variables in PIL (python)?
Question: i'm programing in python 3.1 and using a PIL which are updated for it aswel.
Now it's so that my program is getting info from a webpage and i want this
info to be drawed at a picture which i already got, so i'm using a variable
for this & it's also the part i need help with. What I link is a part of my
program (since it's over 100 lines i'm just showing the parts which i found
realative to the question)

    
    
    import webbrowser
    import random
    import urllib.request, urllib.parse, urllib.error
    import re
    import PIL
    from PIL import Image, ImageFont, ImageDraw
    
    arial16 = ImageFont.truetype ("arial.ttf", 16)
    
    Z = (input ("What is the character name? "))
    
    #The link which i get from my input info..
    url = "http://"+X+".battle.net/wow/en/character/"+Y+"/"+Z+"/simple"
    
    # Read the webpage
    html = urllib.request.urlopen(url).read()
    
    # Encoding
    encoding = "utf-8"
    html =html.decode (encoding)
    
    # Find right class & choose background from it
    cl = re.findall ('class="class">(.*)</a><span class="comma">,</span>', html) 
    
    if "Death Knight" : im = Image.open ("DeathKnightBackground.png")
    elif "Druid" : im = Image.open ("DruidBackground.png")
    elif "Hunter" : im = Image.open ("HunterBackground.png")
    elif "Mage" : im = Image.open ("MageBackground.png")
    elif "Paladin" : im = Image.open ("PaladinBackground.png")
    elif "Priest" : im = Image.open ("PriestBackground.png")
    elif "Rogue" : im = Image.open ("RogueBackground.png")
    elif "Shaman" : im = Image.open ("ShamanBackground.png")
    elif "Warlock" : im = Image.open ("WarlockBackground.png")
    elif "Warrior" : im = Image.open ("WarriorBackground.png")
    
    # Find the Title
    title = re.findall('<div class="title">(.*)</div>', html)
    
    # If i want to print this i just do
    print (("Your Charactername with it's title:")+Z, title)
    print (("You are:"),cl)
    
    # Then i want to use a variable to save my picture
    S = input("Please enter a name to save your forumsignature: ")
    
    # When i want to draw the text to the picture i tried to use (+Z, title) as in the print
    # function - but since this didn't work i will just go with ((+Z, title)) which don't give me
    # syntax error
    
    draw = ImageDraw.Draw ( im )
    draw.text ( (20,20), ((+ Z, title)), font=arial16, fill="white")
    
    # As i said before, i'm using variable S for saving and tried this way.. but in all the ways i
    # have tried, i always keep getting syntax errors 
    
    im.save ((+S))
    
    im.show ((+S))
    

So does anyone know if PIL are able to work with variables in this kind of
way? or does you know some other way to draw text from variables at an image
with python 3.1?

Very cheerful for replies and i will keep trying to test all kind of different
ways i know to get this to work & post up here if i get something to work...

// Zabs


Answer: It is a syntax error. Adding more parenthesis just makes a new datastructure.
Try:

    
    
    text = Z + " " + title
    draw.text ( (20,20), text, font=arial16, fill="white")
    

and for your save command:

    
    
    im.save(S)
    im.show(S)
    

