On Wed, Apr 17, 2002 at 09:43:31AM -0500, Ralph Walden wrote:
> I seem to have an a problem which under
> certain circumstances causes a color to "leak" into the scrollbar
> tracks of my dialogs.
>
> I understand the concept of shared contexts and styles and
> that one must make a copy of a gc before modifying it,
> and I do this, so I don't "think" I'm doing anything stupid.
> (But you never know! :) )
>
> Has anyone else had a mysterious problem
> of this nature?
>
I have had a similar problem, and the behavior was consistent
with the conjecture (unproven) that graphics contexts can
continue to be shared even between distinct copies of
GtkStyle objects, that is to say, that the GtkStyle's
copy routine isn't "deep" in the Python sense.
My naive approach, which had leakage such
as you describe, was to change the foreground color of a shape
in a GtkDrawingArea by copying over the GtkStyle and then
diddling the foreground color in the GtkStyle copy.
I fixed the leak by taking a more thorough approach --
instead of just diddling the colors, I now actually redraw
the object using a fresh graphics context (obtained from the
".new_gc" method of the associated window). This may be
overkill, it's possible that there is a way to assign a new
graphics context into an object without redrawing, but
I never investigated that, nor did I look at the behavior
of objects other than the GtkDrawingArea.
This was pygtk 0.6.8, gtk 1.2.8, Python 2.1
Hope this helps.
-- Andrew Reid
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/