hi,

>>>>> "James" == James Henstridge <[EMAIL PROTECTED]> writes:

<snip>
    James> I would recommend using the size_allocate signal, which is
    James> used in the geometry management code of GTK.  This signal
    James> takes a single argument -- a GtkAllocation structure.
    James> Unfortunately, this signal argument is just marked as a
    James> pointer in the gtk code, so is inaccessible to python
    James> (pygtk just hands you an opaque cobject).
<snip>

    James>   def size_allocate(widget, allocation): x, y, width,
    James> height = widget.get_allocation() # do what you want here

    James>   widget.connect_after("size_allocate", size_allocate)

Thanks! This works fine.  But I still have problems.  Let me explain
the whole thing to make it clear.

As you are aware I am trying to get VTK and pyGtk to work together.  I
have had quite a bit of success and got things working quite well.
However, there was one little bug that was a little irratting.  If you
partially obscured the VTK window and unobscured it completely an
expose event was not emited, so I would catch it using a
visibility_notify and do a redraw.  However, this doesnt work if you
partially obscure a window and keep the window still obscured slightly
but expose a little more of the window.  I dont know how to explain
this better. :( Anyway, the basic problem is because I do a
SetParentInfo on the VTK RenderWindow the embedded window somehow does
not generate proper expose events.  Since I dont know how to fix the
original problem I tried another approach.  

  (1) Basically, create a parent container Widget and add a child to
  it.  Set the vtkRenderWindow's parentId to this childs xid.

  (2) Connect all the mouse/key stuff to this child and connect the
  parents expose event to the redraw.

This works nicely.  But now I have an implementation problem, I
originally derived the GtkVtkRenderWindow from GtkDrawingArea.  This
is not container so I cant add a child.  I then tried connecting the
redraw to the parent's expose but this is a bad way of doing things
due to a lot of reasons.  So I tried to derive it from a GtkEventBox
and added a GtkDrawingArea as a child.  I also tried other widgets
including a GtkViewport.  Even the GtkEventBox has some problems, when
I resize the window sometimes an expose event is generated and
sometimes it is not (this is even without all the ParentId stuff using
the test code I mailed earlier).  Very strange.  OTOH, using a
GtkViewport works fine but sometimes generates two expose events
instead of one!  I also tried using a GtkViewport and added a
GtkEventBox to it as a child.  The bugs with the obscuring etc. are
gone but there are some irritating issues mentioned above that I dont
know what to do about.

So what I'd like to know is: 

  Is the approach that I have taken above okay?  What is the best way
  to get this done?  

  What widgets are meant to be derived from?  Is it better (in terms
  of memory/speed etc.) to use an EventBox instead of a DrawingArea?

  Why do these widgets have funny behaviour? :)

  I can get the GtkVtkRenderWindow working with both a GtkViewport +
  GtkDrawingArea or a GtkEventBox.  Which do I use?

  If you have any other suggestions I'd appreciate them.


BTW how do you get the parent GtkWidget of a particular widget?  The
self.get_window().parent returns a GdkWindow.  I wrote a simple
function that used self.get_toplevel() and went thru the children but
is there a simpler way?

I have subscribed to the pyGtk list so you dont have to bother CCing
me anymore.  If you want to see the GtkVtkRenderWindow code, let me
know and I will mail it to you personally, unless the folks on the
list wont mind.

thanks,

prabhu


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

Reply via email to