SyntaxWarning: name 'color' is assigned to before global declaration global color Python
You don't put a global
declaration immediately before every use of the variable; you use it once, at the beginning of the function in which the variable is declared global:
def menu(arg): global tool global color cnvs.unbind('<Button-1>') if arg == 1: cnvs.bind('<Button-1>', line) elif arg == 2: cnvs.bind('<Button-1>', poly) elif arg == 3: cnvs.bind('<Button-1>', rect) elif arg == 4: cnvs.bind('<B1-Motion>', pencil) elif arg == 5: cnvs.bind('<B1-Motion>', spray) elif arg == 6: cnvs.bind('<B1-Motion>', blotter) elif arg == 7: color = "red" elif arg == 8: color = "black" elif arg == 9: color = "blue" elif arg == 10: color = "purple"