from tkinter import * import colorsys # Hue, Saturation, Value(Brightness) ls_h=[0,30,60,90,120,150,180,210,240,270,300,330] ls_s=[255,128, 64,255,128, 64,255,128, 64] ls_v=[255,255,255,192,192,192,128,128,128] n=len(ls_h) m=len(ls_s) scolor=[] for h in ls_h: for s,v in zip(ls_s,ls_v): r,g,b=colorsys.hsv_to_rgb(h/360, s/255, v/255) ir=int(round(r*255,0)) ig=int(round(g*255,0)) ib=int(round(b*255,0)) hrgb='#' hrgb=hrgb+'{0:0>2x}'.format(ir) hrgb=hrgb+'{0:0>2x}'.format(ig) hrgb=hrgb+'{0:0>2x}'.format(ib) scolor=scolor+[hrgb] #tkinter root = Tk() f1=Frame(root) f2=Frame(root) f3=Frame(root) # frame for 's' and 'v' values for c in range(0,m+1): if c==0: Label(f1,text='HSV',borderwidth=2,relief='raised',bg='#000000',fg='#ffffff',font=('consolas',12,'bold'),width=4,height=1).grid(row=0,column=c) Label(f1,text='h', borderwidth=2,relief='raised',bg='#ffffff',fg='#000000',font=('consolas',12), width=4,height=1).grid(row=1,column=c) else: Label(f1, text='s='+str(ls_s[c-1]),borderwidth=2,relief='raised',bg='#ffffff',fg='#000000',font=('consolas',12),width=8,height=1).grid(row=0,column=c) Label(f1, text='v='+str(ls_v[c-1]),borderwidth=2,relief='raised',bg='#ffffff',fg='#000000',font=('consolas',12),width=8,height=1).grid(row=1,column=c) # frame for 'h' values for r in range(1,n+1): Label(f2, text=str(ls_h[r-1]),borderwidth=2,relief='raised',bg='#ffffff',fg='#000000',font=('consolas',12),width=4,height=2).grid(row=r,column=0) # frame for color labels k=-1 for r in range(0,n): for c in range(0,m): k=k+1 fc='#000000' if 3<=c: fc='#ffffff' Label(f3, text=scolor[k],borderwidth=2,relief='raised',bg=scolor[k],fg=fc,font=('consolas',12),width=8,height=2).grid(row=r,column=c) # pack f1.pack(side=TOP) f2.pack(side=LEFT) f3.pack(side=LEFT) root.mainloop( )