"TypeError: CreateText() takes exactly 8 arguments (5 given)" with default arguments

Posted by Eli Nahon on Stack Overflow See other posts from Stack Overflow or by Eli Nahon
Published on 2012-04-12T05:00:25Z Indexed on 2012/04/12 5:29 UTC
Read the original article Hit count: 487

def CreateText(win, text, x, y, size, font, color, style):
    txtObject = Text(Point(x,y), text)
    if size==None:
        txtObject.setSize(12)
    else:
        txtObject.setSize(size)

    if font==None:
        txtObject.setFace("courier")
    else:
        txtObject.setFace(font)

    if color==None:
        txtObject.setTextColor("black")
    else:
        txtObject.setTextColor(color)

    if style==None:
        txtObject.setStyle("normal")
    else:
        txtObject.setStyle(style)

    return txtObject

def FlashingIntro(win, numTimes):
    txtIntro = CreateText(win, "CELSIUS CONVERTER!", 5,5,28)
    for i in range(numTimes):
        txtIntro.draw(win)
        sleep(.5)
        txtIntro.undraw()
        sleep(.5)

I'm trying to get the CreateText function to create a text object with my "default" values if the parameters are not used. (I've tried it with blank strings "" instead of None and no luck) I'm fairly new to Python and have little programming knowledge.

© Stack Overflow or respective owner

Related posts about python

Related posts about typeerror