Mika Ryynanen wrote:

>I'll repost this because the first one was moderated because of wrong
>subscription email address. I hope this will now go through OK.
>
>On Sun, 25 Nov 2001, Christian Storgaard wrote:
>
>>I'm trying to make a white colour for use in a style, but when I call GdkColor with:
>>      GdkColor(65535,65535,65535)
>>I get:
>>          File "/usr/local/lib/python2.1/site-packages/gtk.py", line 35, in GdkColor
>>          return _gtk.gdk_color_new(red, green, blue, pixel)
>>      OverflowError: signed short integer is greater than maximum
>>
>>I've found out that the highest number I can use with GdkColor in pygtk is 27306.
>>
>
>Are you sure the highest number is 27306? It would make more sense for the
>highest number to be 32767, which is the maximum value of an unsigned
>integer.
>
>I had that problem after upgrading from Python 1.5.2 to version 2.1. 
>I worked around it by modifying gtkmodule.c so it accepts long
>integers instead of shorts, but I think there is another option. You
>could probably convert unsigned values to signed like this (untested):
>
>def to_signed(a):
>    if a & 0x8000:
>        return a - 0x10000
>    else:
>        return a
>
>GdkColor(to_signed(65535), to_signed(65535), to_signed(65535)) 
>
Note that you should really be using the GdkColormap.alloc method to 
allocate colours in order to be portable.  Code like the following:
  cmap = widget.get_colormap()
  colour = cmap.alloc("red")  # you can use strings
  colour = cmap.alloc(0xffff, 0, 0) # or 16-bit quantities

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to