After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 527718 - additional constructor for gtk.gdk.Color
additional constructor for gtk.gdk.Color
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: gdk
Git Master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2008-04-12 15:05 UTC by Paul Pogonyshev
Modified: 2008-04-27 18:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the patch (1.91 KB, patch)
2008-04-12 15:05 UTC, Paul Pogonyshev
committed Details | Review

Description Paul Pogonyshev 2008-04-12 15:05:03 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):
  • File "<stdin>", line 1 in <module>
TypeError: Usage:
  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.
Comment 1 Paul Pogonyshev 2008-04-12 15:05:32 UTC
Created attachment 109122 [details] [review]
the patch
Comment 2 Gustavo Carneiro 2008-04-26 22:23:53 UTC
(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
Comment 3 Johan (not receiving bugmail) Dahlin 2008-04-26 23:03:14 UTC
If Gustavo likes it, just commit ;-)

But you know I am a fan of unit testing, especially for code which is not generated.
Comment 4 Paul Pogonyshev 2008-04-27 18:58:43 UTC
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.