Convert string #ff0000ff to color in python

Benny Schudel's Avatar

Benny Schudel

22 Jan, 2013 09:19 AM


I'm loading custom colors via CSV Import in NodeBox3 but have no clue how to convert them to a real color.
I think I should use a custom Node for that (probably Python) but because there are no examples and documentation I have no clue how to do it.

Thanks for any advice.


  1. Support Staff 1 Posted by Frederik De Ble... on 12 Feb, 2014 08:49 AM

    Frederik De Bleser's Avatar

    The Color class has a constructor that takes a hexadecimal value. Just use

    c = Color("#11223344")

    Here is the Java class for Color.

  2. 2 Posted by jerimee.richir on 10 Sep, 2018 07:39 PM

    jerimee.richir's Avatar

    But how does python have access to the Color class in Java?

  3. Support Staff 3 Posted by john on 12 Sep, 2018 10:33 PM

    john's Avatar

    Hi Jerimee,

    Benny's original question was posted in January, 2013. Since then, after version 3.0.39 in March 2014, it is no longer necessary to create custom nodes to import colors from CSV files.

    If your CSV has a color column with values formatted as hex values (e.g. #ECE8CE), you can just do a lookup on that column and pass the result directly into a color node or to the fill port of a colorize node. Other functions of that Java color class can be handled using existing NodeBox color nodes.

    If your question was not so much about handling colors but about accessing Java code from within custom Python-based nodes, Frederik (NodeBox's creator) is much more knowledgeable than I am. My understanding is that some NodeBox nodes include references to original Java code accessed via Jython, "a version of Python 2.7 that runs on the JVM."

    Please let us know if you are having a specific issue with either handling colors or accessing classes from within custom nodes. I can probably help with the former and Frederick or some other staff member should be able to help with the latter case.



  4. Support Staff 4 Posted by Frederik De Ble... on 14 Sep, 2018 01:53 PM

    Frederik De Bleser's Avatar

    John is absolutely right — the version of Python running in NodeBox is Jython, which has direct access to the Java VM. The Color class is not the one defined in Java, but NodeBox's own, which is loaded into the Jython script for you by default.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

04 Dec, 2023 10:18 PM
04 Dec, 2023 10:14 PM
04 Dec, 2023 11:38 AM
29 Nov, 2023 05:30 AM
28 Nov, 2023 12:38 AM


27 Nov, 2023 04:40 AM
26 Nov, 2023 10:02 AM
22 Nov, 2023 09:33 AM
20 Nov, 2023 08:54 PM
17 Nov, 2023 01:43 AM
15 Nov, 2023 06:58 AM