Advertisement
here2share

# Tk_RGBadv.py

Feb 3rd, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # Tk_RGBadv.py
  2.  
  3. from Tkinter import *
  4.  
  5. root=Tk()
  6. def cmd(event):
  7.     r=red.get()
  8.     g=green.get()
  9.     b=blue.get()
  10.     zfg='WHITE'
  11.     if (r*1.2)+(g*2.4)+b > 460: zfg='BLACK'
  12.     color='#%02x%02x%02x' % (r,g,b)
  13.     if color <> sample.prev:
  14.         sample.prev=color
  15.         print color
  16.     sample.configure(background=color)
  17.     lb.configure(foreground=zfg)
  18.     for z in lz:
  19.         z.configure(background=color)
  20. #
  21.  
  22. sample=Frame(root)
  23. sample.pack(fill=BOTH,expand=1)
  24. la=Label(sample,text='')
  25. lb=Label(sample,text='-- SAMPLE --', fg='WHITE')
  26. lc=Label(sample,text='')
  27. lz=la,lb,lc
  28. for z in lz:
  29.     z.pack(fill=BOTH,expand=1)
  30.  
  31. red= Scale(root,orient='horizontal',label='RED',to=255,length='5c')
  32. red.pack(fill=X)
  33. green= Scale(root,orient='horizontal',label='GREEN',to=255,length='5c')
  34. green.pack(fill=X)
  35. blue= Scale(root,orient='horizontal',label='BLUE',to=255,length='5c')
  36. blue.pack(fill=X)
  37. sample.prev=''
  38. red.configure(command=cmd)
  39. green.configure(command=cmd)
  40. blue.configure(command=cmd)
  41. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement