From: Kevin A. <ka...@us...> - 2004-08-22 18:45:04
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21139 Modified Files: util.py Log Message: added colorFromString to util.py added backgroundInfoDialog function wrapper Index: util.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/util.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** util.py 22 Aug 2004 17:25:58 -0000 1.29 --- util.py 22 Aug 2004 18:44:53 -0000 1.30 *************** *** 343,344 **** --- 343,363 ---- os.spawnv(os.P_NOWAIT, python, [pythonQuoted, filename] + args) """ + + + def colorFromString(s): + s = s.strip() + if s == '': + color = None + elif (s.startswith('(') and s.endswith(')')) or (s.startswith('[') and s.endswith(']')): + # assume a color tuple + try: + r, g, b = s[1:-1].split(',') + color = (int(r), int(g), int(b)) + except: + color = None + else: + # assume color string such as blue or #0000FF + # we could do further verification here + # to avoid an exception being thrown when color is set + color = s + return color |