Le samedi 25 avril 2009 à 11:05 -0700, Brandon Lewis a écrit :
> Bruno Coudoin wrote:
> > Le vendredi 17 avril 2009 à 00:20 -0700, Brandon Lewis a écrit :
> >> I am having some difficulty with setting colors on goocanvas objects on 32-bit
> >> machines. Essentially what I do is pack the values from a gtk.gdk.Color object
> >> into a 32-bit word and assign it to the fill/stroke color properties.
> >>
> >> The problem is that on 32-bit machines, some color values exceed python's limit
> >> on the size of an int (since it has no unsigned type) and get promoted to longs.
> >> When this happens, the goocanvas bindings can't convert the value (which is
> >> still only 32-bits wide)
> >>
> >> Anyone have any suggestions on how to deal with this?
> >
> > You can force python to set a long value by appending an L at the end of
> > the value like in color_rgba= 0xF44B9DFFL
> >
>
> But then goocanvas will reject it. All this does is specify that the literal
> value is a long. The issue is that goocanvas refuses to convert python longs to
> ints even when the value would fit within 32-bits.
I confused. Please give an example of what does not work for you. In
GCompris there are tons of code that sets colors and I got no issue once
I append a L to the value.
--
Bruno Coudoin
http://gcompris.net Free educational software for kids
http://toulibre.org Logiciel Libre à Toulouse
http://april.org Promouvoir et défendre le Logiciel Libre

Thread view

I am having some difficulty with setting colors on goocanvas objects on 32-bit
machines. Essentially what I do is pack the values from a gtk.gdk.Color object
into a 32-bit word and assign it to the fill/stroke color properties.
The problem is that on 32-bit machines, some color values exceed python's limit
on the size of an int (since it has no unsigned type) and get promoted to longs.
When this happens, the goocanvas bindings can't convert the value (which is
still only 32-bits wide)
Anyone have any suggestions on how to deal with this?

On Fri, 2009-04-17 at 00:20 -0700, Brandon Lewis wrote:
> I am having some difficulty with setting colors on goocanvas objects on 32-bit
> machines. Essentially what I do is pack the values from a gtk.gdk.Color object
> into a 32-bit word and assign it to the fill/stroke color properties.
>
> The problem is that on 32-bit machines, some color values exceed python's limit
> on the size of an int (since it has no unsigned type) and get promoted to longs.
> When this happens, the goocanvas bindings can't convert the value (which is
> still only 32-bits wide)
>
> Anyone have any suggestions on how to deal with this?
I don't know python so I can't help much there.
But as a workaround you could create a cairo pattern with the python
equivalent of cairo_pattern_create_rgba() and then set the
"stroke-pattern" or "fill-pattern" properties.
(This looks like another reason to have a utility function to create an
RGBA int from a GdkColor.)
Damon
P.S. This is the old mailing list. The new one is on lists.gnome.org.

Le vendredi 17 avril 2009 à 00:20 -0700, Brandon Lewis a écrit :
> I am having some difficulty with setting colors on goocanvas objects on 32-bit
> machines. Essentially what I do is pack the values from a gtk.gdk.Color object
> into a 32-bit word and assign it to the fill/stroke color properties.
>
> The problem is that on 32-bit machines, some color values exceed python's limit
> on the size of an int (since it has no unsigned type) and get promoted to longs.
> When this happens, the goocanvas bindings can't convert the value (which is
> still only 32-bits wide)
>
> Anyone have any suggestions on how to deal with this?
You can force python to set a long value by appending an L at the end of
the value like in color_rgba= 0xF44B9DFFL
--
Bruno Coudoin
http://gcompris.net Free educational software for kids
http://toulibre.org Logiciel Libre à Toulouse
http://april.org Promouvoir et défendre le Logiciel Libre

Bruno Coudoin wrote:
> Le vendredi 17 avril 2009 à 00:20 -0700, Brandon Lewis a écrit :
>> I am having some difficulty with setting colors on goocanvas objects on 32-bit
>> machines. Essentially what I do is pack the values from a gtk.gdk.Color object
>> into a 32-bit word and assign it to the fill/stroke color properties.
>>
>> The problem is that on 32-bit machines, some color values exceed python's limit
>> on the size of an int (since it has no unsigned type) and get promoted to longs.
>> When this happens, the goocanvas bindings can't convert the value (which is
>> still only 32-bits wide)
>>
>> Anyone have any suggestions on how to deal with this?
>
> You can force python to set a long value by appending an L at the end of
> the value like in color_rgba= 0xF44B9DFFL
>
But then goocanvas will reject it. All this does is specify that the literal
value is a long. The issue is that goocanvas refuses to convert python longs to
ints even when the value would fit within 32-bits.

Le samedi 25 avril 2009 à 11:05 -0700, Brandon Lewis a écrit :
> Bruno Coudoin wrote:
> > Le vendredi 17 avril 2009 à 00:20 -0700, Brandon Lewis a écrit :
> >> I am having some difficulty with setting colors on goocanvas objects on 32-bit
> >> machines. Essentially what I do is pack the values from a gtk.gdk.Color object
> >> into a 32-bit word and assign it to the fill/stroke color properties.
> >>
> >> The problem is that on 32-bit machines, some color values exceed python's limit
> >> on the size of an int (since it has no unsigned type) and get promoted to longs.
> >> When this happens, the goocanvas bindings can't convert the value (which is
> >> still only 32-bits wide)
> >>
> >> Anyone have any suggestions on how to deal with this?
> >
> > You can force python to set a long value by appending an L at the end of
> > the value like in color_rgba= 0xF44B9DFFL
> >
>
> But then goocanvas will reject it. All this does is specify that the literal
> value is a long. The issue is that goocanvas refuses to convert python longs to
> ints even when the value would fit within 32-bits.
I confused. Please give an example of what does not work for you. In
GCompris there are tons of code that sets colors and I got no issue once
I append a L to the value.
--
Bruno Coudoin
http://gcompris.net Free educational software for kids
http://toulibre.org Logiciel Libre à Toulouse
http://april.org Promouvoir et défendre le Logiciel Libre