>>>>> "George" == George A Dowding <[EMAIL PROTECTED]> writes:

    George> Hello, I am looking for information on using Pygtk and
    George> VTK.  I haven't come across anything that explains how to
    George> do that.  If anybody can point me in the right direction,
    George> I would appreciated it.

If you look in Wrapping/Python/vtk/gtk/ you'll see a class
GtkVTKRenderWindow that contains a demo in the __main__ section at the
bottom.  Currently, this works only with a patched version of pygtk
provided by John K Luebs that exposes xid.  You'll have to rebuild
pygtk from cvs with this patch.

It appears that people are moving to gtkglext, however, so I recently
adapted the gtkgl render window that ships with vtk to work with
gtkglext.  The same patch caveat applies.

Also, it currently only works under X windows because I am having
trouble getting pygtkglext working under win32 and hence can't test
the use of hwnd in place of xid for the gtkglext code.  But I expect
to have this resolved soon.  If you need this platform, let me know
and I can provide you with an installer.

Here is some demo code and the gtkglext render window class

The xid, hwnd patch
--- pygtk-1.99.15/gtk/gdk.override.orig	2003-03-07 15:12:46.000000000 -0500
+++ pygtk-1.99.15/gtk/gdk.override	2003-03-07 15:33:16.000000000 -0500
@@ -15,6 +15,12 @@
 #  include <Numeric/arrayobject.h>
 #endif
 
+#if defined(GDK_WINDOWING_X11)
+#include <gdk/gdkx.h>
+#elif defined(GDK_WINDOWING_WIN32)
+#include <gdk/gdkwin32.h>
+#endif
+
 extern PyTypeObject PyGtkWidget_Type;
 
 %%
@@ -1844,6 +1850,30 @@
     return Py_None;
 }
 %%
+override-slot GdkWindow.tp_getattr
+PyObject *
+_wrap_gdk_window_tp_getattr(PyGObject *self, char *attr)
+{
+    GdkWindow *window = GDK_WINDOW(self->obj);
+
+#if defined(GDK_WINDOWING_WIN32)
+    if (!strcmp(attr, "hwnd")) {
+	return PyLong_FromVoidPtr(GDK_WINDOW_HWND(window));
+    }
+#elif defined(GDK_WINDOWING_X11)
+    if (!strcmp(attr, "xid")) {
+	return PyLong_FromUnsignedLong(GDK_WINDOW_XID(window));
+    }
+#endif
+
+    {
+	PyObject *name = PyString_FromString(attr);
+	PyObject *ret = PyObject_GenericGetAttr((PyObject *)self, name);
+	Py_DECREF(name);
+	return ret;
+    }
+}
+%%
 override gdk_window_get_geometry noargs
 static PyObject *
 _wrap_gdk_window_get_geometry(PyGObject *self)
The gtkglext class:

Attachment: GtkGLExtVTKRenderWindow.py
Description: Binary data

Some demo code:

Attachment: cylinder_demo.py
Description: Binary data


I'm using CVS pygtk1.99.15, VTK4.2 and python 2.2 on redhat linux 8.

If you need more info or help, let me know.

John Hunter
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to