title: PyGObject, hex color to Gdk.RGBA
body: <p>i found this code</p>
  
  <pre><code>gdk_rgba_parse ()
  </code></pre>
  
  <p>which should allow me to do something like</p>
  
  <pre><code>Gdk.RGBA.parse(#7F7F7F)
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code> TypeError: unbound method parse() must be called with RGBA instance as first argument   (got str instance instead)
  </code></pre>
  
  <p>using the RGBA color ( in percent, from 0 to 1 )</p>
  
  <p>Docs:</p>
  
  <p><a href="https://developer.gnome.org/gdk3/stable/gdk3-RGBA-Colors.html#gdk-rgba-parse" rel="nofollow">https://developer.gnome.org/gdk3/stable/gdk3-RGBA-Colors.html#gdk-rgba-parse</a>
  <a href="http://www.crategus.com/books/cl-cffi-gtk/pages/gdk_fun_gdk-rgba-parse.html" rel="nofollow">http://www.crategus.com/books/cl-cffi-gtk/pages/gdk_fun_gdk-rgba-parse.html</a></p>
  
  <p>But I'm kinda lost, i struggle to translate from C to PyGOBject and understanding the arguments of the function.. any help would be appreciated!</p>
  
  <hr>
  
  <p>Since i didn't find the right solution, i made this converter:</p>
  
  <pre><code>def hex_to_rgba(value):
      value = value.lstrip('#')
      if len(value) == 3:
          value = ''.join([v*2 for v in list(value)])
      (r1,g1,b1,a1)=tuple(int(value[i:i+2], 16) for i in range(0, 6, 2))+(1,) 
      (r1,g1,b1,a1)=(r1/255.00000,g1/255.00000,b1/255.00000,a1)
  
      return (r1,g1,b1,a1)
  </code></pre>
  
  <p>It works..</p>