Module mikro
[hide private]
[frames] | no frames]

Module mikro

source code

Mini Kross - a scripting solution inspired by Kross (http://kross.dipe.org/) Technically this is one of the most important modules in ScripterNG. Via the Qt meta object system it provides access to unwrapped objects. This code uses a lot of metaprogramming magic. To fully understand it, you have to know about metaclasses in Python

Classes [hide private]
  Error
Base error classed.
  PyQtClass
Base class
  PyQtProperty
  PyQtMethod
Functions [hide private]
 
from_variantlist(variantlist)
convert QList<QVariant> to a normal Python list
source code
 
classname(obj)
return real class name Unwrapped classes will be represended in PyQt by a known base class.
source code
 
from_variant(variant)
convert a QVariant to a Python value
source code
 
supercast(obj)
cast a QObject subclass to the best known wrapped super class
source code
 
wrap(obj, force=False)
If a class is not known by PyQt it will be automatically casted to a known wrapped super class.
source code
 
is_wrapped(obj)
checks if a object is wrapped by PyQtClass
source code
 
unwrap(obj)
if wrapped returns the wrapped object
source code
 
is_qobject(obj)
checks if class or wrapped class is a subclass of QObject
source code
 
is_scripterng_child(qobj)
walk up the object tree until ScripterNG or the root is found
source code
 
create_pyqt_class(metaobject) source code
PyQtClass object
create_pyqt_object(obj)
Wrap a QObject and make all slots and properties dynamically available.
source code
Variables [hide private]
  variant_converter = {"QVariantList": lambda v: from_variantlis...
  qtclasses = {}
  pyqt_classes = {}
Function Details [hide private]

classname(obj)

source code 

return real class name Unwrapped classes will be represended in PyQt by a known base class. So obj.__class__.__name__ will not return the desired class name

wrap(obj, force=False)

source code 

If a class is not known by PyQt it will be automatically casted to a known wrapped super class. But that limits access to methods and propperties of this super class. So instead this functions returns a wrapper class (PyQtClass) which queries the metaObject and provides access to all slots and all properties.

create_pyqt_object(obj)

source code 

Wrap a QObject and make all slots and properties dynamically available.

Parameters:
  • obj (QObject) - an unwrapped QObject
Returns: PyQtClass object
dynamicaly created object with all available properties and slots

This is probably the only function you need from this module. Everything else are helper functions and classes.


Variables Details [hide private]

variant_converter

Value:
{"QVariantList": lambda v: from_variantlist(v), "QList<QVariant>": lam\
bda v: v.toList(), "int": lambda v: v.toInt() [0], "double": lambda v:\
 v.toDouble() [0], "char": lambda v: v.toChar(), "QByteArray": lambda \
v: v.toByteArray(), "QString": lambda v: unicode(v.toString()), "QPoin\
t": lambda v: v.toPoint(), "QPointF": lambda v: v.toPointF(), "QSize":\
 lambda v: v.toSize(), "QLine": lambda v: v.toLine(), "QStringList": l\
ambda v: v.toStringList(), "QTime": lambda v: v.toTime(), "QDateTime":\
 lambda v: v.toDateTime(), "QDate": lambda v: v.toDate(), "QLocale": l\
...