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 want the fallback text to be 12pt black courier. I've tried it with blank strings ""
instead of None
and no luck. I'm fairly new to Python and have little programming knowledge.