Advertisement
Mashudi

scriptcontoh

Nov 2nd, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. #!/usr/bin/python
  2. import gtk, sys
  3. def tohex(c):
  4.    #Convert to hex string
  5.    #little hack to fix bug
  6.    s = ['#',hex(int(c[0]*256))[2:].zfill(2),hex(int(c[1]*256))[2:].zfill(2),hex(int(c[2]*256))[2:].zfill(2)]
  7.    for item in enumerate(s):
  8.       if item[1]=='100':
  9.          s[item[0]]='ff'
  10.    print s
  11.    return ''.join(s)
  12. csd = gtk.ColorSelectionDialog('Gnome Color Chooser')
  13. cs = csd.colorsel
  14. cs.set_has_opacity_control(True)
  15. cs.set_current_alpha(65536)
  16. if csd.run()!=gtk.RESPONSE_OK:
  17.    print 'No color selected.'
  18.    sys.exit()
  19. c = cs.get_current_color()
  20. print "Color Values:"
  21. print 'red:',c.red
  22. print 'green:',c.green
  23. print 'blue:',c.blue
  24. print 'alpha:',cs.get_current_alpha()
  25. print "Hex Codes:"
  26. print tohex((c.red/65536.0, c.green/65536.0, c.blue/65536.0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement