# # colors # coded by Kenar # REF: Tcl\lib\tk8.0\demos\colors.tcl # from Canvas import * import sys, string from Tkinter import * colors=''' black darkgray gray lightgray white snow seashell AntiqueWhite bisque PeachPuff NavajoWhite LemonChiffon cornsilk ivory honeydew LavenderBlush MistyRose azure SlateBlue RoyalBlue blue DodgerBlue SteelBlue DeepSkyBlue SkyBlue LightSkyBlue LightSteelBlue LightBlue LightCyan PaleTurquoise CadetBlue turquoise cyan SlateGray DarkSlateGray aquamarine DarkSeaGreen SeaGreen PaleGreen SpringGreen green chartreuse OliveDrab DarkOliveGreen khaki LightGoldenrod LightYellow yellow gold goldenrod DarkGoldenrod RosyBrown IndianRed sienna burlywood wheat tan chocolate firebrick brown salmon LightSalmon orange DarkOrange coral tomato OrangeRed red DeepPink HotPink pink LightPink PaleVioletRed maroon VioletRed magenta orchid plum MediumOrchid DarkOrchid purple MediumPurple thistle ''' colorlist=string.split(colors) numcolor=len(colorlist) def pr(event): global t n,m=event.x/20,event.y/20 num=16*m+n if num >= numcolor: return t.delete() color=colorlist[num] red,green,blue=c.winfo_rgb(color) red=red/256 green=green/256 blue=blue/256 t=CanvasText(c,150,120, text="%s #%02X%02X%02X"%(color,red,green,blue), anchor="w") c=Canvas(width=320,height=140,background='white') c.pack() c.bind("",pr) n,m=0,0 for color in colorlist: Rectangle(c, 20*n, 20*m, 20*n+20, 20*m+20, fill=color) n=n+1 if n == 16: n=0; m=m+1 t=CanvasText(c,150,420,text="") c.mainloop()