On Fri, Mar 07, 2003 at 04:25:03PM -0600, John Hunter wrote:
> 
> I am trying to make a vtk renderwindow for pygtk2.  The code I am
> using as my starting point makes a call
> 
>     def OnRealize(self, *args):
>         if self.__Created == 0:
>             # you can't get the xid without the window being realized.
>             self.realize()
>             win_id = str(self.window.xid)
>             self._RenderWindow.SetWindowInfo(win_id)
>             self.__Created = 1
>         return gtk.TRUE
> 
> self extends gtk.Window
> 
> But this 'xid' attribute appears to no longer exist.  Is there a way
> to get a window ID, preferably in a cross platform way?
>

The concept of a window ID is not cross platform so I think a "cross
platform" method is misleading. GDK has two macros: GDK_WINDOW_XID and
GDK_WINDOW_HWND. I'm not familiar with the FB stuff. This will expose
attributes: xid and hwnd that will do the proper conversion and return
them in a Python long.

Try the patch below.

Is it possible to get this feature added to PyGTK?

--jkl

--- 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)


_______________________________________________
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