Advertisement
here2share

# Tk_xy2rgb.py

Oct 25th, 2021
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. # Tk_xy2rgb.py
  2.  
  3. from Tkinter import *
  4. from ctypes import windll
  5.  
  6. root = Tk()
  7.  
  8. def click(event):
  9.     dc = windll.user32.GetDC(0)
  10.     rgb = windll.gdi32.GetPixel(dc,event.x_root,event.y_root)
  11.     r = rgb & 0xff
  12.     g = (rgb >> 8) & 0xff
  13.     b = (rgb >> 16) & 0xff
  14.     print r,g,b
  15.  
  16. for i in ['red', 'green', 'blue', 'black', 'white']:
  17.     Label(root, width=30, background=i).pack()
  18.  
  19. root.bind('<Button-1>', click)
  20.  
  21. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement