[pygtk] custom container class; installing child properties
David E. Konerding
dekonerding at lbl.gov
Fri Jan 20 04:49:32 WST 2006
Johan Dahlin wrote:
> David E. Konerding wrote:
>
>> Hi folks,
>>
>> I am trying to build a custom container. This container is like a
>> layout, but it doesn't manage its own bin_window (since I can't for
>> the life of my find a way to make a gtk.Widget have a transparent
>> background so that stuff drawn to the parent of the widget gets
>> occluded by the container's gtk.gdk.Window).
>
>
> I did something similar to this during the last weekend,
> I also refactored the interesting parts into an example, to be able to
> copy/paste from when you want to implement a scrollable container.
>
> http://cvs.gnome.org/viewcvs/gnome-python/pygtk/examples/gtk/scrollable.py?view=markup
>
>
> Does that help you?
>
Hi Johan,
I adapted the example you listed, basically removing any code that had
to do with the custom Container having a window or a bin window.
Instead, the child gets added to the bin_window of the custom
Container's parent. This gets me *really* close, except that when
I attempt to adjust the child widget's x, y by adding in the coordinates
of the custom Container on its parent, I get some ugly gtk runtime
exceptions
when the custom Container attempts to propage its expose event to its
children (child->parent == GTK_WIDGET(container) assert fails).
I wonder if my attempt to reach my goal this way is just the wrong
idea. My goal is an app with a gtk.Layout with
draggable objects (basic non-zoomable canvas). The draggable objects
are usually images with transparency information. However, now
I want to make some custom objects which are "composites" of several
gtk.Widgets that all drag together. Orignally
I attempted to use a gtk.Layout (child of the Canvas gtk.Layout) that
contains all the items of the composite widget. But the problem there
is that the
gtk.Layout obscures any drawing I do to the parent canvas (I use
"draw_lines" to draw lines on the canvas connecting draggable objects).
I've attached an example of what I mean: actually, the Frame object
seems to work ok, in that the line drawn on the outer canvas
actually covers the Frame. However, the "composite" object completely
occludes the underlying line. I've tried to play with transparent
pixmap backgrounds for the inner layout, but haven't had any luck.
Dave
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.png
Type: image/png
Size: 9445 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20060119/63ca20b3/example.png
More information about the pygtk
mailing list