问题
I use PyGObject/PyGI and GStreamer to show a video in my GUI. The video is shown in a Gtk.DrawingArea and therefore I need to get it's window-handle in the realize-signal-handler. On Linux I can simply use drawing_area.get_property('window').get_xid()
and on Windows I have to access the C-API (like described here):
drawingarea_window = drawingarea.get_property('window')
ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object]
drawingarea_gpointer = ctypes.pythonapi.PyCapsule_GetPointer(drawingarea_window.__gpointer__, None)
gdkdll = ctypes.CDLL ('libgdk-3-0.dll')
self._drawingarea_handle = gdkdll.gdk_win32_window_get_handle(drawingarea_gpointer)
Now I want the same on MacOS. Since it is not using X11, but Quartz, I tried to use the C-API again. But this time to call gdk_quartz_window_get_nswindow
instead of gdk_win32_window_get_handle
(see gdkwindow-quartz.c):
// ... same lines as in Windows-example
gdkdll = ctypes.CDLL ('libgdk-3.0.dylib')
self._drawingarea_handle = gdkdll.gdk_quartz_window_get_nswindow(drawingarea_gpointer)
But this leads just to a Segmentation fault: 11
.
Any ideas on how to get the handle on MacOS?
来源:https://stackoverflow.com/questions/35669176/get-the-window-handle-in-pygi-on-macos