def convert_color(color):
if color is not None:<EOL><INDENT>if isinstance(color, str):<EOL><INDENT>color = color.strip()<EOL>if color[<NUM_LIT:0>] == "<STR_LIT:#>":<EOL><INDENT>if len(color) != <NUM_LIT:7>:<EOL><INDENT>raise ValueError("<STR_LIT>".format(color))<EOL><DEDENT>else:<EOL><INDENT>hex_colors = (color[<NUM_LIT:1>:<NUM_LIT:3>], color[<NUM_LIT:3>:<NUM_LIT:5>], color[<NUM_LIT:5>:<NUM_LIT:7>])<EOL>for hex_color in hex_colors:<EOL><INDENT>try:<EOL><INDENT>int_color = int(hex_color, <NUM_LIT:16>)<EOL><DEDENT>except:<EOL><INDENT>raise ValueError("<STR_LIT>".format(hex_color))<EOL><DEDENT>if not (<NUM_LIT:0> <= int_color <= <NUM_LIT:255>):<EOL><INDENT>raise ValueError("<STR_LIT>".format(hex_color))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>no_of_colors = len(color)<EOL><DEDENT>except:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if no_of_colors != <NUM_LIT:3>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>for c in color:<EOL><INDENT>if not (<NUM_LIT:0> <= c <= <NUM_LIT:255>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>color = "<STR_LIT>".format(color[<NUM_LIT:0>], color[<NUM_LIT:1>], color[<NUM_LIT:2>])<EOL><DEDENT><DEDENT>return color<EOL>
Converts a color from "color", (255, 255, 255) or "#ffffff" into a color tk 
should understand.