Esempio n. 1
0
 def wrapper(obj, *args):
     # XXX: support kwargs?
     qargs = [Q_ARG(t, v) for t, v in zip(self.args, args)]
     invoke_args = [obj._instance, self.name]
     invoke_args.append(Qt.DirectConnection)
     rtype = self.returnType
     if rtype:
         invoke_args.append(Q_RETURN_ARG(rtype))
     invoke_args.extend(qargs)
     try:
         result = QMetaObject.invokeMethod(*invoke_args)
         error_msg = str(qApp.property("MIKRO_EXCEPTION").toString())
         if error_msg:
             # clear message
             qApp.setProperty("MIKRO_EXCEPTION", QVariant())
             raise Error(error_msg)
     except RuntimeError, e:
         raise TypeError, \
             "%s.%s(%r) call failed: %s" % (obj, self.name, args, e)
Esempio n. 2
0
 def wrapper(obj, *args):
     # XXX: support kwargs?
     qargs = [Q_ARG(t, v) for t, v in zip(self.args, args)]
     invoke_args = [obj._instance, self.name]
     invoke_args.append(Qt.DirectConnection)
     rtype = self.returnType
     if rtype:
         invoke_args.append(Q_RETURN_ARG(rtype))
     invoke_args.extend(qargs)
     try:
         result = QMetaObject.invokeMethod(*invoke_args)
         error_msg = str(qApp.property("MIKRO_EXCEPTION").toString())
         if error_msg:
             # clear message
             qApp.setProperty("MIKRO_EXCEPTION", QVariant())
             raise Error(error_msg)
     except RuntimeError, e:
         raise TypeError, \
             "%s.%s(%r) call failed: %s" % (obj, self.name, args, e)
Esempio n. 3
0
def init():
	global embpyqt
	embpyqt = wrap_instance(qApp.property("embedded_pyqt").toPyObject())
	embpyqt.executionRequested.connect(execute)
		
	global_namespace.update(
	  embpyqt=embpyqt,
	  embpyqt_console=wrap_instance(Console(execute))
	)

	# add classes to global_namespace
	for class_name in embpyqt.availableClasses():
		cls = class_by_name(class_name)
		global_namespace[str(class_name)] = cls


	# add existing instances to global_namespace
	for obj_name in embpyqt.availableObjects():
		obj = embpyqt.objectByName(obj_name)
		global_namespace[str(obj_name)] = obj
	
	#base_namespace.update(global_namespace)

		
	# if the env var DUMP_STUBS is set create a stub file 
	if os.environ.get("DUMP_STUBS", None):
		from embeddedpyqt.stubgen import StubCreator
		stubs = StubCreator()
		for cls in global_namespace.values():
			stubs.add_class(cls)
		target = "/tmp/embpyqtstubs.py"
		open(target, "w").write(str(stubs))
		print target, "written"

	# add global_namespace variables to globals
	for k, v in global_namespace.items():
		globals()[k] = v