Convert RGB value to Hex
Jump to navigation
Jump to search
This is a simple script that does one function: converts RGB decimal values to hex. As initially created, it will only do one value at a time. While it would be nice to allow this to remain open while you work with Scribus, this initial version will have to be closed to carry out any Scribus operations.
Usage
- Start the script – there are no requirements other than running it from Scribus. One could certainly alter this to run outside of Scribus by eliminating the valueDialog and messageBox features.
- Enter an RGB decimal value in the initial dialog. If you enter nothing, the value '255' is the default.
- When you are finished, enter '0' (the number zero, not the letter O).
#!/usr/bin/env python # File:rgb2hex.py # simple utility to convert rgb values to hex # within Scribus import scribus colorN = 255 while colorN != 0: color = scribus.valueDialog('Color Values','Enter the RGB value, 0 to quit') if color == '': color = '255' colorN = int(color) hexN = hex(colorN) result = scribus.messageBox ('Hex Value','RGB value of '+ color + ' is \n Hex value of '+ hexN,scribus.BUTTON_OK)
To Do
- I would like to add the ability to enter the complete RGB values for a given color. Just needs some parsing, maybe a tuple.
- Also want to trim the result to eliminate the '0x' from the front to the hex result.