Python RGB Convertor

A handy python script I made to convert 8-bit colour codes to openGL/Renderman style RGB. Someone else might find use for it, designed to run from terminal. I have the following alias in my bashrc:

alias rgbConv='~/./rgbConverter.py'

This then lets me run it from terminal easily. You just need to put it in your home directory and change the name if necessary.

Feel free to copy it from below

#!/usr/bin/python
#Using code from http://www.answermysearches.com/python-how-to-copy-and-paste-to-the-clipboard-in-linux/286/
#to handle the clipboard
import pygtk
pygtk.require('2.0')
import gtk
import sys
print "RGB Converted!"
r = float(sys.argv[1])
g = float(sys.argv[2])
b = float(sys.argv[3])
if(r>255):
    r = 255
if(g>255):
    g = 255
if(b>255):
    b = 255
rgb = str('%.2f' % (r/255) +'f'+ ','
        + '%.2f' % (g/255) +'f'+ ','
        + '%.2f' % (b/255) +'f')
clipboard = gtk.clipboard_get()
text = clipboard.wait_for_text()
clipboard.set_text(rgb)
clipboard.store()