GNOME Bugzilla – Bug 527718
additional constructor for gtk.gdk.Color
Last modified: 2008-04-27 18:58:43 UTC
Suggested in comment #4 for bug 526189. In principle, this is an API change, so should probably be delayed till the next stable release. With the patch you can pass a single string as to gtk.gdk.color_parse(): >>> x = gtk.gdk.Color('red') >>> x.red, x.green, x.blue (65535, 0, 0) >>> x = gtk.gdk.Color('#ff0000') >>> x.red, x.green, x.blue (65535, 0, 0) >>> x = gtk.gdk.Color(65535, 0, 0) >>> x.red, x.green, x.blue (65535, 0, 0) Erroneous arguments: >>> gtk.gdk.Color([]) Traceback (most recent call last):
+ Trace 195039
gtk.gdk.Color(red, green, blue, pixel) [all are optional] gtk.gdk.Color(spec) [see gtk.gdk.color_parse()] This error message is already used in many places in PyGTK.
Created attachment 109122 [details] [review] the patch
(In reply to comment #1) > Created an attachment (id=109122) [edit] > the patch Code wise, the patch looks good to me. I think it is a good idea. But whether/when to apply I leave to Johan, as I am kind of away pygtk development lately... :P
If Gustavo likes it, just commit ;-) But you know I am a fan of unit testing, especially for code which is not generated.
Sending ChangeLog Sending gtk/gdkcolor.override Sending tests/test_conversion.py Transmitting file data ... Committed revision 2968. I added a couple unit tests there. Committed only to the trunk, not to newly-created pygtk-2-12 branch.