在MacOS上获取PyGI中的窗口句柄

时间:2016-02-27 11:32:16

标签: macos ctypes gtk3 pygobject python-gstreamer

我使用PyGObject / PyGI和GStreamer在我的GUI中显示视频。视频显示在Gtk.DrawingArea中,因此我需要在realize-signal-handler中获取它的窗口句柄。在Linux上我可以简单地使用drawing_area.get_property('window').get_xid(),在Windows上我必须访问C-API(如描述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)

现在我想在MacOS上使用相同的功能。由于它不使用X11,而是使用Quartz,我尝试再次使用C-API。但这次要拨打gdk_quartz_window_get_nswindow而不是gdk_win32_window_get_handle(请参阅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)

但这只会导致Segmentation fault: 11
有关如何处理MacOS的任何想法吗?

0 个答案:

没有答案