Updated QtDeclarative modue to works with python 2.x and 3.x

This commit is contained in:
Renato Filho 2011-10-06 11:33:59 -03:00 • committed by Hugo Parente Lima
commit 75843bf45a
4 changed files with 5 additions and 7 deletions

View file

@ -197,12 +197,11 @@ void propListTpFree(void* self)
PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self); PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self);
delete reinterpret_cast<DeclarativeListProperty*>(PySide::Property::userData(pySelf)); delete reinterpret_cast<DeclarativeListProperty*>(PySide::Property::userData(pySelf));
// calls base type constructor // calls base type constructor
pySelf->ob_type->tp_base->tp_free(self); Py_TYPE(pySelf)->tp_base->tp_free(self);
} }
PyTypeObject PropertyListType = { PyTypeObject PropertyListType = {
PyObject_HEAD_INIT(0) PyVarObject_HEAD_INIT(0, 0)
0, /*ob_size*/
"ListProperty", /*tp_name*/ "ListProperty", /*tp_name*/
sizeof(PySideProperty), /*tp_basicsize*/ sizeof(PySideProperty), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/

View file

@ -9,5 +9,5 @@ view.resize(200, 200)
item = view.itemAt(100, 100) item = view.itemAt(100, 100)
# it CAN NOT crash here # it CAN NOT crash here
print item print(item)

View file

@ -41,7 +41,6 @@ class TestQDeclarativeView(TimedQApplication):
def testModelExport(self): def testModelExport(self):
print "TEST"
view = QDeclarativeView() view = QDeclarativeView()
dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")] dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]

View file

@ -50,7 +50,7 @@ class PieChart (QDeclarativeItem):
def __init__(self, parent = None): def __init__(self, parent = None):
QDeclarativeItem.__init__(self, parent) QDeclarativeItem.__init__(self, parent)
self._name = u'' self._name = ''
self._slices = [] self._slices = []
def getName(self): def getName(self):
@ -59,7 +59,7 @@ class PieChart (QDeclarativeItem):
def setName(self, value): def setName(self, value):
self._name = value self._name = value
name = Property(unicode, getName, setName) name = Property(str, getName, setName)
def appendSlice(self, _slice): def appendSlice(self, _slice):
global appendCalled global appendCalled