Advertisement
here2share

# Tk_RGB.py

Feb 2nd, 2018
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # Tk_RGB.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.     color='#%02x%02x%02x' % (r,g,b)
  11.     if color <> sample.prev:
  12.         sample.prev=color
  13.         print color
  14.     sample.configure(background=color)
  15.     for z in lz:
  16.         z.configure(background=color)
  17. #
  18.  
  19. sample=Frame(root)
  20. sample.pack(fill=BOTH,expand=1)
  21. la=Label(sample,text='')
  22. lb=Label(sample,text='-- SAMPLE --')
  23. lc=Label(sample,text='-- SAMPLE --', fg='WHITE')
  24. ld=Label(sample,text='')
  25. lz=la,lb,lc,ld
  26. for z in lz:
  27.     z.pack(fill=BOTH,expand=1)
  28.  
  29. red= Scale(root,orient='horizontal',label='RED',to=255,length='5c')
  30. red.pack(fill=X)
  31. green= Scale(root,orient='horizontal',label='GREEN',to=255,length='5c')
  32. green.pack(fill=X)
  33. blue= Scale(root,orient='horizontal',label='BLUE',to=255,length='5c')
  34. blue.pack(fill=X)
  35. sample.prev=''
  36. red.configure(command=cmd)
  37. green.configure(command=cmd)
  38. blue.configure(command=cmd)
  39. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement