Пример #1
0
def pycobj_from_lp(lp):
    """
  @param  ctypes.voidp
  @return  pyobject  PyObject
  """
    try:
        return pythonapi.PyCObject_FromVoidPtr(lp, 0)
    except ArgumentError:
        return lp
Пример #2
0
    def TWidgetToPySideWidget(form, ctx=sys.modules['__main__']):
        """
        Use this method to convert a TWidget* to a QWidget to be used by PySide

        @param ctx: Context. Reference to a module that already imported QtWidgets module
        """
        if form is None:
            return None
        if type(form).__name__ == "SwigPyObject":
            # Since 'form' is a SwigPyObject, we first need to convert it to a PyCObject.
            # However, there's no easy way of doing it, so we'll use a rather brutal approach:
            # converting the SwigPyObject to a 'long' (will go through 'SwigPyObject_long',
            # that will return the pointer's value as a long), and then convert that value
            # back to a pointer into a PyCObject.
            ptr_l = long(form)
            from ctypes import pythonapi, c_void_p, py_object
            pythonapi.PyCObject_FromVoidPtr.restype = py_object
            pythonapi.PyCObject_AsVoidPtr.argtypes = [c_void_p, c_void_p]
            form = pythonapi.PyCObject_FromVoidPtr(ptr_l, 0)
        return ctx.QtGui.QWidget.FromCObject(form)
Пример #3
0
def create_dummy_pycobject():
    return pythonapi.PyCObject_FromVoidPtr(0, 0)